Isis 3 Programmer Reference
Stretch.h
1 #ifndef Stretch_h
2 #define Stretch_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include <vector>
10 #include <string>
11 #include "Pvl.h"
12 #include "ImageHistogram.h"
13 #include "Histogram.h"
14 
15 namespace Isis {
58  class Stretch {
59  private:
60  std::vector<double> p_input;
61  std::vector<double> p_output;
62  int p_pairs;
63 
64  double p_null;
66  double p_lis;
68  double p_lrs;
70  double p_his;
72  double p_hrs;
74  double p_minimum;
75  double p_maximum;
76 
77  std::pair<double, double> NextPair(QString &pairs);
78 
79  public:
80  Stretch();
81 
83  ~Stretch() {};
84 
85  void AddPair(const double input, const double output);
86 
94  void SetNull(const double value) {
95  p_null = value;
96  }
97 
105  void SetLis(const double value) {
106  p_lis = value;
107  }
108 
116  void SetLrs(const double value) {
117  p_lrs = value;
118  }
119 
127  void SetHis(const double value) {
128  p_his = value;
129  }
130 
138  void SetHrs(const double value) {
139  p_hrs = value;
140  }
141 
142  void SetMinimum(const double value) {
143  p_minimum = value;
144  }
145  void SetMaximum(const double value) {
146  p_maximum = value;
147  }
148 
149  void Load(Pvl &pvl, QString &grpName);
150  void Save(Pvl &pvl, QString &grpName);
151  void Load(QString &file, QString &grpName);
152  void Save(QString &file, QString &grpName);
153 
154  double Map(const double value) const;
155 
156  void Parse(const QString &pairs);
157  void Parse(const QString &pairs, const Isis::Histogram *hist);
158 
159  QString Text() const;
160 
162  int Pairs() const {
163  return p_pairs;
164  };
165 
166  double Input(const int index) const;
167  double Output(const int index) const;
168 
170  void ClearPairs() {
171  p_pairs = 0;
172  p_input.clear();
173  p_output.clear();
174  };
175 
176  void CopyPairs(const Stretch &other);
177  };
178 };
179 
180 #endif
Isis::Stretch::p_minimum
double p_minimum
By default this value is set to p_lrs.
Definition: Stretch.h:74
Isis::Stretch::p_null
double p_null
Mapping of input NULL values go to this value (default NULL)
Definition: Stretch.h:64
Isis::Stretch::SetLis
void SetLis(const double value)
Sets the mapping for LIS pixels.
Definition: Stretch.h:105
Isis::Stretch
Pixel value mapper.
Definition: Stretch.h:58
Isis::Stretch::SetHrs
void SetHrs(const double value)
Sets the mapping for HRS pixels.
Definition: Stretch.h:138
Isis::Stretch::Pairs
int Pairs() const
Returns the number of stretch pairs.
Definition: Stretch.h:162
Isis::Stretch::SetLrs
void SetLrs(const double value)
Sets the mapping for LRS pixels.
Definition: Stretch.h:116
Isis::Stretch::SetHis
void SetHis(const double value)
Sets the mapping for HIS pixels.
Definition: Stretch.h:127
Isis::Stretch::NextPair
std::pair< double, double > NextPair(QString &pairs)
Given a string containing stretch pairs for example "0:0 50:0 100:255 255:255" evaluate the first pai...
Definition: Stretch.cpp:145
Isis::Stretch::CopyPairs
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
Definition: Stretch.cpp:392
Isis::Stretch::Parse
void Parse(const QString &pairs)
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair.
Definition: Stretch.cpp:181
Isis::Stretch::p_pairs
int p_pairs
Number of stretch pairs.
Definition: Stretch.h:62
Isis::Stretch::p_his
double p_his
Mapping of input HIS values go to this value (default HIS)
Definition: Stretch.h:70
Isis::Stretch::p_input
std::vector< double > p_input
Array for input side of stretch pairs.
Definition: Stretch.h:60
Isis::Stretch::AddPair
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
Definition: Stretch.cpp:48
Isis::Stretch::ClearPairs
void ClearPairs()
Clears the stretch pairs.
Definition: Stretch.h:170
Isis::Stretch::p_hrs
double p_hrs
Mapping of input HRS values go to this value (default HRS)
Definition: Stretch.h:72
Isis::Stretch::Text
QString Text() const
Converts stretch pair to a string.
Definition: Stretch.cpp:268
Isis::Stretch::Stretch
Stretch()
Constructs a Stretch object with default mapping of special pixel values to themselves.
Definition: Stretch.cpp:25
Isis::Stretch::Output
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index.
Definition: Stretch.cpp:302
Isis::Stretch::p_maximum
double p_maximum
By default this value is set to p_hrs.
Definition: Stretch.h:75
Isis::Stretch::SetNull
void SetNull(const double value)
Sets the mapping for NULL pixels.
Definition: Stretch.h:94
Isis::Stretch::p_lis
double p_lis
Mapping of input LIS values go to this value (default LIS)
Definition: Stretch.h:66
Isis::Histogram
Container of a cube histogram.
Definition: Histogram.h:74
Isis::Stretch::Load
void Load(Pvl &pvl, QString &grpName)
Loads the stretch pairs from the pvl file into the Stretch object.
Definition: Stretch.cpp:342
Isis::Stretch::p_output
std::vector< double > p_output
Array for output side of stretch pairs.
Definition: Stretch.h:61
Isis::Stretch::p_lrs
double p_lrs
Mapping of input LRS values go to this value (default LRS)
Definition: Stretch.h:68
Isis::Stretch::~Stretch
~Stretch()
Destroys the Stretch object.
Definition: Stretch.h:83
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Stretch::Input
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index.
Definition: Stretch.cpp:287
Isis::Stretch::Map
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
Definition: Stretch.cpp:69