Isis 3 Programmer Reference
|
#include <Stretch.h>
Public Member Functions | |
Stretch () | |
Constructs a Stretch object with default mapping of special pixel values to themselves. More... | |
~Stretch () | |
Destroys the Stretch object. More... | |
void | AddPair (const double input, const double output) |
Adds a stretch pair to the list of pairs. More... | |
void | SetNull (const double value) |
Sets the mapping for NULL pixels. More... | |
void | SetLis (const double value) |
Sets the mapping for LIS pixels. More... | |
void | SetLrs (const double value) |
Sets the mapping for LRS pixels. More... | |
void | SetHis (const double value) |
Sets the mapping for HIS pixels. More... | |
void | SetHrs (const double value) |
Sets the mapping for HRS pixels. More... | |
void | SetMinimum (const double value) |
void | SetMaximum (const double value) |
void | Load (Pvl &pvl, QString &grpName) |
Loads the stretch pairs from the pvl file into the Stretch object. More... | |
void | Save (Pvl &pvl, QString &grpName) |
void | Load (QString &file, QString &grpName) |
Loads the stretch pairs from the pvl file into the Stretch object. More... | |
void | Save (QString &file, QString &grpName) |
Saves the stretch pairs in the Stretch object into the given pvl file. More... | |
double | Map (const double value) const |
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings. More... | |
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. More... | |
void | Parse (const QString &pairs, const Isis::Histogram *hist) |
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair where the input is a percentage. More... | |
QString | Text () const |
Converts stretch pair to a string. More... | |
int | Pairs () const |
Returns the number of stretch pairs. More... | |
double | Input (const int index) const |
Returns the value of the input side of the stretch pair at the specified index. More... | |
double | Output (const int index) const |
Returns the value of the output side of the stretch pair at the specified index. More... | |
void | ClearPairs () |
Clears the stretch pairs. More... | |
void | CopyPairs (const Stretch &other) |
Copies the stretch pairs from another Stretch object, but maintains special pixel values. More... | |
Private Member Functions | |
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 pair and return a pair of doubles where first is the first input and second is the first output. More... | |
Private Attributes | |
std::vector< double > | p_input |
Array for input side of stretch pairs. More... | |
std::vector< double > | p_output |
Array for output side of stretch pairs. More... | |
int | p_pairs |
Number of stretch pairs. More... | |
double | p_null |
Mapping of input NULL values go to this value (default NULL) More... | |
double | p_lis |
Mapping of input LIS values go to this value (default LIS) More... | |
double | p_lrs |
Mapping of input LRS values go to this value (default LRS) More... | |
double | p_his |
Mapping of input HIS values go to this value (default HIS) More... | |
double | p_hrs |
Mapping of input HRS values go to this value (default HRS) More... | |
double | p_minimum |
By default this value is set to p_lrs. More... | |
double | p_maximum |
By default this value is set to p_hrs. More... | |
Pixel value mapper.
This class is used to stretch or remap pixel values. For example, it can be used to apply contrast stretches, color code stretches, or remap from a double range to 8-bit (0 to 255). The methodology used is straightforward. The program must set up a list of stretch pairs, input-to-output mappings, using the AddPair method. For example, (0,0) and (1,255) are two pairs which would cause an input of 0 to be mapped to 0, 0.5 would be mapped to 127.5 and 1 would be mapped to 255. More than two pairs can be used which generates piece-wise linear mappings. Special pixels are mapped to themselves unless overridden with methods such as SetNull. Input values outside the minimum and maximum input pair values are mapped to LRS and HRS respectively.
If you would like to see Stretch being used in implementation, see stretch.cpp
2002-09-17 Jeff Anderson - Added Parse method
2003-05-16 Stuart Sides - Modified schema from astrogeology... isis.astrogeology...
2005-02-16 Elizabeth Ribelin - Modified file to support Doxygen documentation
2005-03-11 Elizabeth Ribelin - Modified unitTest to test all methods in the class
2006-05-25 Jacob Danton - Fixed typo in documentation
2007-03-02 Elizabeth Miller - Added Load and Save methods
2008-11-12 Steven Lambright - Changed search algorithm into a binary search replacing a linear search.
2009-04-30 Eric Hyer - Modified parse method. New private method NextPair() now handles low level details of parsing. Created second Parse method for handling pairs where the input side is a perentage. Fixed Input and Output getters to check both sides of boundry condition for valid data
Isis::Stretch::Stretch | ( | ) |
Constructs a Stretch object with default mapping of special pixel values to themselves.
Definition at line 41 of file Stretch.cpp.
|
inline |
void Isis::Stretch::AddPair | ( | const double | input, |
const double | output | ||
) |
Adds a stretch pair to the list of pairs.
Note that all input pairs must be in ascending order.
input | Input value to map |
output | Output value when the input is mapped |
Isis::IException::Programmer | - input pairs must be in ascending order |
Definition at line 63 of file Stretch.cpp.
References _FILEINFO_.
Referenced by Isis::BinaryStretchType::calculateNewStretch(), Isis::SawtoothStretchType::calculateNewStretch(), Isis::StretchTool::changeStretch(), Isis::ChipViewport::computeStretch(), Isis::LinearStretchType::endEditChanged(), Isis::MosaicSceneItem::getStretch(), Isis::VisualDisplay::setPixelData(), Isis::BinaryStretchType::setStretch(), Isis::LinearStretchType::setStretch(), Isis::StretchTool::setStretchAcrossBands(), Isis::LinearStretchType::startEditChanged(), Isis::StretchTool::stretchBand(), and Isis::StretchTool::stretchBuffer().
|
inline |
Clears the stretch pairs.
Definition at line 184 of file Stretch.h.
References p_input, p_output, and p_pairs.
Referenced by Isis::StretchTool::advancedStretchChanged(), Isis::StretchTool::changeStretch(), Isis::ChipViewport::computeStretch(), Isis::VisualDisplay::setPixelData(), Isis::StretchTool::setStretchAcrossBands(), Isis::StretchTool::stretchBand(), and Isis::StretchTool::stretchRect().
void Isis::Stretch::CopyPairs | ( | const Stretch & | other | ) |
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
other | - The Stretch to copy pairs from |
Definition at line 407 of file Stretch.cpp.
References p_input, p_output, and p_pairs.
Referenced by Isis::StretchTool::advancedStretchChanged(), Isis::BinaryStretchType::endEditChanged(), Isis::LinearStretchType::endEditChanged(), Isis::SawtoothStretchType::offsetEditChanged(), Isis::IndependentCubeViewport::restretch(), Isis::LinearStretchType::setStretch(), Isis::BinaryStretchType::setStretch(), Isis::ManualStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), Isis::StretchTool::setStretchAllViewports(), Isis::BinaryStretchType::startEditChanged(), Isis::LinearStretchType::startEditChanged(), Isis::CubeViewport::stretchGray(), Isis::StretchTool::stretchRect(), Isis::StretchTool::stretchRequested(), and Isis::SawtoothStretchType::widthEditChanged().
double Isis::Stretch::Input | ( | const int | index | ) | const |
Returns the value of the input side of the stretch pair at the specified index.
If the index number is out of bounds, then the method returns -1
index | The index number to retrieve the input stretch pair value from |
Definition at line 302 of file Stretch.cpp.
Referenced by Isis::LinearStretchType::endEditChanged(), Isis::BinaryStretchType::setStretch(), Isis::LinearStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), Isis::HistogramWidget::setStretch(), Isis::LinearStretchType::startEditChanged(), Isis::StretchTool::stretchChanged(), and Isis::StretchType::updateTable().
void Isis::Stretch::Load | ( | Isis::Pvl & | pvl, |
QString & | grpName | ||
) |
Loads the stretch pairs from the pvl file into the Stretch object.
The pvl should look similar to this:
pvl | - The pvl containing the stretch pairs |
grpName | - The group name to get the input and output keywords from |
Definition at line 357 of file Stretch.cpp.
References _FILEINFO_, Isis::PvlObject::findGroup(), Isis::PvlContainer::findKeyword(), Isis::PvlKeyword::size(), Isis::toDouble(), and Isis::PvlObject::Traverse.
void Isis::Stretch::Load | ( | QString & | file, |
QString & | grpName | ||
) |
Loads the stretch pairs from the pvl file into the Stretch object.
The file should look similar to this:
file | - The input file containing the stretch pairs |
grpName | - The group name to get the input and output keywords from |
Definition at line 338 of file Stretch.cpp.
double Isis::Stretch::Map | ( | const double | value | ) | const |
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
value | Value to map |
Definition at line 84 of file Stretch.cpp.
References Isis::IsHisPixel(), Isis::IsHrsPixel(), Isis::IsLisPixel(), Isis::IsNullPixel(), and Isis::IsValidPixel().
Referenced by Isis::MosaicSceneItem::drawImage(), Isis::ChipViewport::paintImage(), Isis::VisualDisplay::paintPixmap(), and Isis::CubeViewport::paintPixmap().
|
private |
Given a string containing stretch pairs for example "0:0 50:0 100:255 255:255" evaluate the first pair and return a pair of doubles where first is the first input and second is the first output.
pairs | A string containing stretch pairs for example "0:0 50:0 100:255 255:255" |
Isis::IException::User | - invalid stretch pair |
Definition at line 160 of file Stretch.cpp.
References Isis::Null, and Isis::toDouble().
double Isis::Stretch::Output | ( | const int | index | ) | const |
Returns the value of the output side of the stretch pair at the specified index.
If the index number is out of bounds, then the method returns -1.
index | The index number to retieve the output stretch pair value from |
Definition at line 317 of file Stretch.cpp.
Referenced by Isis::BinaryStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), Isis::HistogramWidget::setStretch(), and Isis::StretchType::updateTable().
|
inline |
Returns the number of stretch pairs.
Definition at line 176 of file Stretch.h.
References p_pairs.
Referenced by Isis::BinaryStretchType::setStretch(), Isis::LinearStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), Isis::HistogramWidget::setStretch(), Isis::CubeViewport::stretchBlue(), Isis::StretchTool::stretchBuffer(), Isis::StretchTool::stretchChanged(), Isis::CubeViewport::stretchGray(), Isis::CubeViewport::stretchGreen(), Isis::CubeViewport::stretchRed(), and Isis::StretchType::updateTable().
void Isis::Stretch::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.
Therefore, the user can enter a string in this form and this method will parse the string and load the stretch pairs into the object via AddPairs.
pairs | A string containing stretch pairs for example "0:0 50:0 100:255 255:255" |
Isis::IException::User | - invalid stretch pair |
Definition at line 196 of file Stretch.cpp.
References _FILEINFO_.
Referenced by Isis::CubeViewport::stretchBlue(), Isis::CubeViewport::stretchGray(), Isis::CubeViewport::stretchGreen(), and Isis::CubeViewport::stretchRed().
void Isis::Stretch::Parse | ( | const QString & | pairs, |
const Isis::Histogram * | hist | ||
) |
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair where the input is a percentage.
Using the Histogram an appropriate dn value will be calculated for each input percentage. Therefore, the user can enter a string in this form and this method will parse the string and load the stretch pairs into the object via AddPairs.
pairs | A string containing stretch pairs for example "0:0 50:0 100:255" |
Isis::IException::User | - invalid stretch pair |
Definition at line 233 of file Stretch.cpp.
References _FILEINFO_, and Isis::Histogram::Percent().
void Isis::Stretch::Save | ( | QString & | file, |
QString & | grpName | ||
) |
Saves the stretch pairs in the Stretch object into the given pvl file.
file | - The file that the stretch pairs will be written to |
grpName | - The name of the group to create and put the stretch pairs into. The group will contain two keywords, Input, and Output. |
Definition at line 382 of file Stretch.cpp.
References Isis::Pvl::write().
|
inline |
Sets the mapping for HIS pixels.
If not called the HIS pixels will be mapped to HIS. Otherwise you can map HIS to any double value. For example, SetHis(255.0).
value | Value to map input HIS |
Definition at line 141 of file Stretch.h.
References p_his.
Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().
|
inline |
Sets the mapping for HRS pixels.
If not called the HRS pixels will be mapped to HRS. Otherwise you can map HRS to any double value. For example, SetHrs(255.0).
value | Value to map input HRS |
Definition at line 152 of file Stretch.h.
References p_hrs.
Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().
|
inline |
Sets the mapping for LIS pixels.
If not called the LIS pixels will be mapped to LIS. Otherwise you can map LIS to any double value. For example, SetLis(0.0).
value | Value to map input LIS |
Definition at line 119 of file Stretch.h.
References p_lis.
Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().
|
inline |
Sets the mapping for LRS pixels.
If not called the LRS pixels will be mapped to LRS. Otherwise you can map LRS to any double value. For example, SetLrs(0.0).
value | Value to map input LRS |
Definition at line 130 of file Stretch.h.
References p_lrs.
Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().
|
inline |
Sets the mapping for NULL pixels.
If not called the NULL pixels will be mapped to NULL. Otherwise you can map NULLs to any double value. For example, SetNull(0.0).
value | Value to map input NULLs |
Definition at line 108 of file Stretch.h.
References p_null.
Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().
QString Isis::Stretch::Text | ( | ) | const |
Converts stretch pair to a string.
Definition at line 283 of file Stretch.cpp.
References Isis::toString().
Referenced by Isis::BinaryStretchType::endEditChanged(), Isis::LinearStretchType::endEditChanged(), Isis::SawtoothStretchType::offsetEditChanged(), Isis::StretchType::savePairs(), Isis::LinearStretchType::setStretch(), Isis::BinaryStretchType::setStretch(), Isis::ManualStretchType::setStretch(), Isis::BinaryStretchType::startEditChanged(), Isis::LinearStretchType::startEditChanged(), and Isis::SawtoothStretchType::widthEditChanged().
|
private |
|
private |
|
private |
Array for input side of stretch pairs.
Definition at line 74 of file Stretch.h.
Referenced by ClearPairs(), and CopyPairs().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Array for output side of stretch pairs.
Definition at line 75 of file Stretch.h.
Referenced by ClearPairs(), and CopyPairs().
|
private |
Number of stretch pairs.
Definition at line 76 of file Stretch.h.
Referenced by ClearPairs(), CopyPairs(), and Pairs().