Isis 3 Programmer Reference
Isis::CubeStretch Class Reference

Stores stretch information for a cube. More...

#include <CubeStretch.h>

Inheritance diagram for Isis::CubeStretch:
Inheritance graph
Collaboration diagram for Isis::CubeStretch:
Collaboration graph

Public Member Functions

 CubeStretch (QString name="DefaultStretch", QString stretchType="Default", int bandNumber=1)
 Constructs a CubeStretch object with default mapping of special pixel values to themselves and a provided name, and a provided stretch type. More...
 
 CubeStretch (CubeStretch const &stretch)
 Copy constructor for a CubeStretch. More...
 
 CubeStretch (Stretch const &stretch)
 Constructs a CubeStretch object from a normal Stretch. More...
 
 CubeStretch (Stretch const &stretch, QString type)
 Constructs a CubeStretch object from a normal Stretch. More...
 
 CubeStretch (Blob blob)
 Constructs a CubeStretch from a Blob. More...
 
bool operator== (CubeStretch &stretch2)
 Check if the CubeStretches are equal. More...
 
Isis::Blob toBlob () const
 Serialize the CubeStretch to a Blob. More...
 
QString getType () const
 Get the Type of Stretch. More...
 
void setType (QString stretchType)
 Set the type of Stretch. More...
 
QString getName () const
 Get the Stretch name. More...
 
void setName (QString name)
 Set the Stretch name. More...
 
int getBandNumber () const
 Get the band number for the stretch. More...
 
void setBandNumber (int bandNumber)
 Set the band number for the stretch. 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 Load (QString &file, QString &grpName)
 Loads the stretch pairs from the pvl file into the Stretch object. More...
 
void Save (Pvl &pvl, QString &grpName)
 
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

QString m_name
 
QString m_type
 The name of the stretch. More...
 
int m_bandNumber
 Type of stretch. This is only currently used in the AdvancedStretchTool. More...
 
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...
 

Detailed Description

Stores stretch information for a cube.

Stores stretch pairs, band number associated with the stretch, and the stretch type from the Advanced Stretch Tool (or 'Default' if not specified)

Author
2020-07-28 Kristin Berry
History:
2020-07-28 Kristin Berry - Original Version

Definition at line 27 of file CubeStretch.h.

Constructor & Destructor Documentation

◆ CubeStretch() [1/5]

Isis::CubeStretch::CubeStretch ( QString  name = "DefaultStretch",
QString  stretchType = "Default",
int  bandNumber = 1 
)

Constructs a CubeStretch object with default mapping of special pixel values to themselves and a provided name, and a provided stretch type.

Parameters
nameName to use for Stretch
typeType of stretch

Definition at line 19 of file CubeStretch.cpp.

◆ CubeStretch() [2/5]

Isis::CubeStretch::CubeStretch ( CubeStretch const &  stretch)

Copy constructor for a CubeStretch.

Definition at line 27 of file CubeStretch.cpp.

References getBandNumber(), getName(), getType(), m_bandNumber, and m_type.

◆ CubeStretch() [3/5]

Isis::CubeStretch::CubeStretch ( Stretch const &  stretch)

Constructs a CubeStretch object from a normal Stretch.

Parameters
StretchStretch to construct the CubeStretch from.

Definition at line 39 of file CubeStretch.cpp.

References m_bandNumber, and m_type.

◆ CubeStretch() [4/5]

Isis::CubeStretch::CubeStretch ( Stretch const &  stretch,
QString  stretchType 
)

Constructs a CubeStretch object from a normal Stretch.

Parameters
StretchStretch to construct the CubeStretch from.

Definition at line 51 of file CubeStretch.cpp.

References m_bandNumber.

◆ CubeStretch() [5/5]

Isis::CubeStretch::CubeStretch ( Blob  blob)

Constructs a CubeStretch from a Blob.

Parameters
blobThe Blob to read data from.

Definition at line 62 of file CubeStretch.cpp.

References Isis::Blob::getBuffer(), Isis::Blob::Label(), Isis::Stretch::Parse(), setBandNumber(), setName(), setType(), and Isis::Blob::Size().

Member Function Documentation

◆ AddPair()

void Isis::Stretch::AddPair ( const double  input,
const double  output 
)
inherited

◆ ClearPairs()

◆ CopyPairs()

◆ getBandNumber()

int Isis::CubeStretch::getBandNumber ( ) const

Get the band number for the stretch.

Returns
int band number

Definition at line 155 of file CubeStretch.cpp.

References m_bandNumber.

Referenced by CubeStretch(), operator==(), and toBlob().

◆ getName()

QString Isis::CubeStretch::getName ( ) const

Get the Stretch name.

Returns
QString name of stretch

Definition at line 145 of file CubeStretch.cpp.

Referenced by CubeStretch(), operator==(), and toBlob().

◆ getType()

QString Isis::CubeStretch::getType ( ) const

Get the Type of Stretch.

Returns
QString Type of Stretch.

Definition at line 115 of file CubeStretch.cpp.

References m_type.

Referenced by CubeStretch(), Isis::AdvancedStretch::restoreSavedStretch(), and toBlob().

◆ Input()

double Isis::Stretch::Input ( const int  index) const
inherited

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

Parameters
indexThe index number to retrieve the input stretch pair value from
Returns
double The input side of the stretch pair at the specified index

Definition at line 287 of file Stretch.cpp.

Referenced by Isis::LinearStretchType::endEditChanged(), Isis::HistogramWidget::setStretch(), Isis::BinaryStretchType::setStretch(), Isis::LinearStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), Isis::LinearStretchType::startEditChanged(), Isis::StretchTool::stretchChanged(), and Isis::StretchType::updateTable().

◆ Load() [1/2]

void Isis::Stretch::Load ( Isis::Pvl pvl,
QString &  grpName 
)
inherited

Loads the stretch pairs from the pvl file into the Stretch object.

The pvl should look similar to this:

Group = Pairs
Input = (0,100,255)
Output = (255,100,0)
EndGroup
Parameters
pvl- The pvl containing the stretch pairs
grpName- The group name to get the input and output keywords from

Definition at line 342 of file Stretch.cpp.

References Isis::PvlObject::findGroup(), Isis::PvlContainer::findKeyword(), Isis::PvlKeyword::size(), Isis::toDouble(), and Isis::PvlObject::Traverse.

◆ Load() [2/2]

void Isis::Stretch::Load ( QString &  file,
QString &  grpName 
)
inherited

Loads the stretch pairs from the pvl file into the Stretch object.

The file should look similar to this:

Group = Pairs
Input = (0,100,255)
Output = (255,100,0)
EndGroup
Parameters
file- The input file containing the stretch pairs
grpName- The group name to get the input and output keywords from

Definition at line 323 of file Stretch.cpp.

◆ Map()

double Isis::Stretch::Map ( const double  value) const
inherited

Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.

Parameters
valueValue to map
Returns
double The mapped output value is returned by this method

Definition at line 69 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().

◆ NextPair()

std::pair< double, double > Isis::Stretch::NextPair ( QString &  pairs)
privateinherited

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.

Parameters
pairsA string containing stretch pairs for example "0:0 50:0 100:255 255:255"
Exceptions
Isis::IException::User- invalid stretch pair
Returns
std::pair of doubles where first is the first input and second is the first output

Definition at line 145 of file Stretch.cpp.

References Isis::Null, and Isis::toDouble().

◆ operator==()

bool Isis::CubeStretch::operator== ( CubeStretch stretch2)

Check if the CubeStretches are equal.

Parameters
stretch2The stretch to compare with
Returns
bool True if stretches are equal. Else, false.

Definition at line 103 of file CubeStretch.cpp.

References getBandNumber(), getName(), and Isis::Stretch::Text().

◆ Output()

double Isis::Stretch::Output ( const int  index) const
inherited

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.

Parameters
indexThe index number to retieve the output stretch pair value from
Returns
double The output side of the stretch pair at the specified index

Definition at line 302 of file Stretch.cpp.

Referenced by Isis::HistogramWidget::setStretch(), Isis::BinaryStretchType::setStretch(), Isis::SawtoothStretchType::setStretch(), and Isis::StretchType::updateTable().

◆ Pairs()

◆ Parse() [1/2]

void Isis::Stretch::Parse ( const QString &  pairs)
inherited

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.

Parameters
pairsA string containing stretch pairs for example "0:0 50:0 100:255 255:255"
Exceptions
Isis::IException::User- invalid stretch pair

Definition at line 181 of file Stretch.cpp.

Referenced by CubeStretch(), Isis::CubeViewport::stretchBlue(), Isis::CubeViewport::stretchGray(), Isis::CubeViewport::stretchGreen(), and Isis::CubeViewport::stretchRed().

◆ Parse() [2/2]

void Isis::Stretch::Parse ( const QString &  pairs,
const Isis::Histogram hist 
)
inherited

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.

Parameters
pairsA string containing stretch pairs for example "0:0 50:0 100:255"
Exceptions
Isis::IException::User- invalid stretch pair

Definition at line 218 of file Stretch.cpp.

References Isis::Histogram::Percent().

◆ Save()

void Isis::Stretch::Save ( QString &  file,
QString &  grpName 
)
inherited

Saves the stretch pairs in the Stretch object into the given pvl file.

Parameters
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 367 of file Stretch.cpp.

References Isis::Pvl::write().

◆ setBandNumber()

void Isis::CubeStretch::setBandNumber ( int  bandNumber)

Set the band number for the stretch.

Parameters
intband number

Definition at line 165 of file CubeStretch.cpp.

References m_bandNumber.

Referenced by CubeStretch(), and Isis::StretchTool::saveStretchToCube().

◆ SetHis()

void Isis::Stretch::SetHis ( const double  value)
inlineinherited

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).

Parameters
valueValue to map input HIS

Definition at line 127 of file Stretch.h.

References Isis::Stretch::p_his.

Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().

◆ SetHrs()

void Isis::Stretch::SetHrs ( const double  value)
inlineinherited

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).

Parameters
valueValue to map input HRS

Definition at line 138 of file Stretch.h.

References Isis::Stretch::p_hrs.

Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().

◆ SetLis()

void Isis::Stretch::SetLis ( const double  value)
inlineinherited

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).

Parameters
valueValue to map input LIS

Definition at line 105 of file Stretch.h.

References Isis::Stretch::p_lis.

Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().

◆ SetLrs()

void Isis::Stretch::SetLrs ( const double  value)
inlineinherited

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).

Parameters
valueValue to map input LRS

Definition at line 116 of file Stretch.h.

References Isis::Stretch::p_lrs.

Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().

◆ setName()

void Isis::CubeStretch::setName ( QString  name)

Set the Stretch name.

Parameters
QStringname for stretch

Definition at line 135 of file CubeStretch.cpp.

Referenced by CubeStretch(), and Isis::StretchTool::saveStretchToCube().

◆ SetNull()

void Isis::Stretch::SetNull ( const double  value)
inlineinherited

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).

Parameters
valueValue to map input NULLs

Definition at line 94 of file Stretch.h.

References Isis::Stretch::p_null.

Referenced by Isis::SpecialPixelTool::apply(), Isis::MosaicSceneItem::getStretch(), Isis::QStretch::QStretch(), and Isis::VisualDisplay::VisualDisplay().

◆ setType()

void Isis::CubeStretch::setType ( QString  stretchType)

Set the type of Stretch.

Parameters
QStringType of Stretch.

Definition at line 125 of file CubeStretch.cpp.

References m_type.

Referenced by CubeStretch().

◆ Text()

◆ toBlob()

Isis::Blob Isis::CubeStretch::toBlob ( ) const

Serialize the CubeStretch to a Blob.

The stretch will be serialized as a string. See Stretch::Text for more information.

Returns
Blob a Blob containing the stretch data.

Definition at line 84 of file CubeStretch.cpp.

References getBandNumber(), getName(), getType(), Isis::Blob::Label(), Isis::Blob::setData(), and Isis::Stretch::Text().

Referenced by Isis::StretchTool::saveStretchToCube(), and Isis::Cube::write().

Member Data Documentation

◆ m_bandNumber

int Isis::CubeStretch::m_bandNumber
private

Type of stretch. This is only currently used in the AdvancedStretchTool.

Definition at line 53 of file CubeStretch.h.

Referenced by CubeStretch(), getBandNumber(), and setBandNumber().

◆ m_type

QString Isis::CubeStretch::m_type
private

The name of the stretch.

Definition at line 52 of file CubeStretch.h.

Referenced by CubeStretch(), getType(), and setType().

◆ p_his

double Isis::Stretch::p_his
privateinherited

Mapping of input HIS values go to this value (default HIS)

Definition at line 70 of file Stretch.h.

Referenced by Isis::Stretch::SetHis().

◆ p_hrs

double Isis::Stretch::p_hrs
privateinherited

Mapping of input HRS values go to this value (default HRS)

Definition at line 72 of file Stretch.h.

Referenced by Isis::Stretch::SetHrs().

◆ p_input

std::vector<double> Isis::Stretch::p_input
privateinherited

Array for input side of stretch pairs.

Definition at line 60 of file Stretch.h.

Referenced by Isis::Stretch::ClearPairs(), and Isis::Stretch::CopyPairs().

◆ p_lis

double Isis::Stretch::p_lis
privateinherited

Mapping of input LIS values go to this value (default LIS)

Definition at line 66 of file Stretch.h.

Referenced by Isis::Stretch::SetLis().

◆ p_lrs

double Isis::Stretch::p_lrs
privateinherited

Mapping of input LRS values go to this value (default LRS)

Definition at line 68 of file Stretch.h.

Referenced by Isis::Stretch::SetLrs().

◆ p_maximum

double Isis::Stretch::p_maximum
privateinherited

By default this value is set to p_hrs.

Definition at line 75 of file Stretch.h.

◆ p_minimum

double Isis::Stretch::p_minimum
privateinherited

By default this value is set to p_lrs.

Definition at line 74 of file Stretch.h.

◆ p_null

double Isis::Stretch::p_null
privateinherited

Mapping of input NULL values go to this value (default NULL)

Definition at line 64 of file Stretch.h.

Referenced by Isis::Stretch::SetNull().

◆ p_output

std::vector<double> Isis::Stretch::p_output
privateinherited

Array for output side of stretch pairs.

Definition at line 61 of file Stretch.h.

Referenced by Isis::Stretch::ClearPairs(), and Isis::Stretch::CopyPairs().

◆ p_pairs

int Isis::Stretch::p_pairs
privateinherited

Number of stretch pairs.

Definition at line 62 of file Stretch.h.

Referenced by Isis::Stretch::ClearPairs(), Isis::Stretch::CopyPairs(), and Isis::Stretch::Pairs().


The documentation for this class was generated from the following files:
Isis::Stretch::Pairs
int Pairs() const
Returns the number of stretch pairs.
Definition: Stretch.h:162
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::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