Isis Developer Reference
Stretch.h
Go to the documentation of this file.
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
Stretch.h
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::Stretch::SetMinimum
void SetMinimum(const double value)
Definition: Stretch.h:142
Isis::Histogram::Percent
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Definition: Histogram.cpp:351
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Histogram.h
Isis::Stretch::SetLis
void SetLis(const double value)
Sets the mapping for LIS pixels.
Definition: Stretch.h:105
Isis::PvlContainer::addKeyword
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Definition: PvlContainer.cpp:202
SpecialPixel.h
Isis::PvlKeyword::addValue
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:252
Isis::Stretch::SetMaximum
void SetMaximum(const double value)
Definition: Stretch.h:145
Isis::Stretch
Pixel value mapper.
Definition: Stretch.h:58
Isis::IsNullPixel
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Definition: SpecialPixel.h:235
Isis::IsHrsPixel
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
Definition: SpecialPixel.h:271
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
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::Pvl::write
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence.
Definition: Pvl.cpp:130
Isis::HIGH_REPR_SAT8
const double HIGH_REPR_SAT8
Definition: SpecialPixel.h:116
QStringList
Isis::Stretch::SetLrs
void SetLrs(const double value)
Sets the mapping for LRS pixels.
Definition: Stretch.h:116
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
IString.h
Isis::Stretch::SetHis
void SetHis(const double value)
Sets the mapping for HIS pixels.
Definition: Stretch.h:127
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
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::Save
void Save(Pvl &pvl, QString &grpName)
Definition: Stretch.cpp:373
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::NULL8
const double NULL8
Definition: SpecialPixel.h:94
ImageHistogram.h
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::HIGH_INSTR_SAT8
const double HIGH_INSTR_SAT8
Definition: SpecialPixel.h:110
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::IException
Isis exception class.
Definition: IException.h:91
Isis::IsLisPixel
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
Definition: SpecialPixel.h:295
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
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::PvlObject::addGroup
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:186
Isis::IsHisPixel
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
Definition: SpecialPixel.h:283
IException.h
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
Isis::Stretch::SetNull
void SetNull(const double value)
Sets the mapping for NULL pixels.
Definition: Stretch.h:94
std
Namespace for the standard library.
Isis::Histogram
Container of a cube histogram.
Definition: Histogram.h:74
Isis::IsValidPixel
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
Definition: SpecialPixel.h:223
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::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::PvlContainer::findKeyword
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Definition: PvlContainer.cpp:62
Isis::LOW_REPR_SAT8
const double LOW_REPR_SAT8
Definition: SpecialPixel.h:98
Isis::LOW_INSTR_SAT8
const double LOW_INSTR_SAT8
Definition: SpecialPixel.h:104
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