Isis Developer Reference
Isis::Chip Class Reference

A small chip of data used for pattern matching. More...

#include <Chip.h>

Collaboration diagram for Isis::Chip:
Collaboration graph

Public Member Functions

 Chip ()
 Constructs a Chip. More...
 
 Chip (const Chip &other)
 Constructs a copy of the passed in chip. More...
 
 Chip (const int samples, const int lines)
 Construct a Chip with specified dimensions. More...
 
virtual ~Chip ()
 Destroys the Chip object. More...
 
void SetSize (const int samples, const int lines)
 Change the size of the Chip. More...
 
bool IsInsideChip (double sample, double line)
 
int Samples () const
 
int Lines () const
 
QString FileName () const
 
void SetAllValues (const double &d)
 Single value assignment operator. More...
 
void SetValue (int sample, int line, const double &value)
 Sets a value in the chip. More...
 
double GetValue (int sample, int line)
 Loads a Chip with a value. More...
 
double GetValue (int sample, int line) const
 Get a value from a Chip. More...
 
void TackCube (const double cubeSample, const double cubeLine)
 This sets which cube position will be located at the chip tack position. More...
 
int TackSample () const
 This method returns a chip's fixed tack sample; the middle of the chip. More...
 
int TackLine () const
 This method returns a chip's fixed tack line; the middle of the chip. More...
 
void Load (Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
 Load cube data into the Chip. More...
 
void Load (Cube &cube, Chip &match, Cube &matchChipCube, const double scale=1.0, const int band=1)
 Loads cube data into the Chip. More...
 
void Load (Cube &cube, const Affine &affine, const bool &keepPoly=true, const int band=1)
 Load a chip using an Affine transform as provided by caller. More...
 
void SetChipPosition (const double sample, const double line)
 Compute the position of the cube given a chip coordinate. More...
 
double CubeSample () const
 
double CubeLine () const
 
void SetCubePosition (const double sample, const double line)
 Compute the position of the chip given a cube coordinate. More...
 
double ChipSample () const
 
double ChipLine () const
 
void SetValidRange (const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
 Set the valid range of data in the chip. More...
 
bool IsValid (int sample, int line)
 
bool IsValid (double percentage)
 Return if total number of valid pixels in chip meets a specified percentage of the entire chip. More...
 
Chip Extract (int samples, int lines, int samp, int line)
 Extract a sub-chip from a chip. More...
 
void Extract (int samp, int line, Chip &output)
 Extract a subchip centered at the designated coordinate. More...
 
Isis::StatisticsStatistics ()
 Returns a statistics object of the current data in the chip. More...
 
void Extract (Chip &output, Affine &affine)
 Extract a subchip of this chip using an Affine transform. More...
 
void Write (const QString &filename)
 Writes the contents of the Chip to a cube. More...
 
void SetClipPolygon (const geos::geom::MultiPolygon &clipPolygon)
 Sets the clipping polygon for this chip. More...
 
Chipoperator= (const Chip &other)
 Copy assignment operator. More...
 
const AffineGetTransform () const
 Returns the Affine transformation of chip-to-cube indices. More...
 
void SetTransform (const Affine &affine, const bool &keepPoly=true)
 Sets the internal Affine transform to new translation. More...
 
Interpolator::interpType GetReadInterpolator ()
 Access method that returns the Interpolator Type used for loading a chip. More...
 
void SetReadInterpolator (const Interpolator::interpType type)
 Sets Interpolator Type for loading a chip. More...
 

Detailed Description

A small chip of data used for pattern matching.

A chip is a small rectangular area that can be used for pattern matching. Data can be loaded into the chip manually or by reading directly from a cube.

Author
2005-05-05 Jeff Anderson
See also
AutoReg
AutoRegFactory

Constructor & Destructor Documentation

◆ Chip() [1/3]

Isis::Chip::Chip ( )

Constructs a Chip.

The default size is 3x3.

◆ Chip() [2/3]

Isis::Chip::Chip ( const Chip other)

Constructs a copy of the passed in chip.

Parameters
otherthe chip to be copied

◆ Chip() [3/3]

Isis::Chip::Chip ( const int  samples,
const int  lines 
)

Construct a Chip with specified dimensions.

Parameters
samplesnumber of samples in the chip
linesnumber of lines in the chip

◆ ~Chip()

Isis::Chip::~Chip ( )
virtual

Destroys the Chip object.

Member Function Documentation

◆ ChipLine()

double Isis::Chip::ChipLine ( ) const
inline
Returns
The chip line after invoking SetCubePosition

Referenced by Isis::ChipViewport::cubeToViewport(), Isis::Centroid::select(), and Isis::AutoReg::SetSubpixelPosition().

◆ ChipSample()

double Isis::Chip::ChipSample ( ) const
inline
Returns
The chip sample after invoking SetCubePosition

Referenced by Isis::ChipViewport::cubeToViewport(), Isis::Centroid::select(), and Isis::AutoReg::SetSubpixelPosition().

◆ CubeLine()

◆ CubeSample()

◆ Extract() [1/3]

void Isis::Chip::Extract ( Chip chipped,
Affine affine 
)

Extract a subchip of this chip using an Affine transform.

This method will translate the data in this chip using an Affine transform to the output chip as provided. Note that the Affine transformation is only applied within the confines of this chip. No file I/O is performed.

A proper Affine transform should not deviate too much from the identity as the mapping operation may result in a NULL filled chip. The operation of this affine is added to the existing affine so proper relationship to the input cube (and any affine operations applied at load time) is preserved. This implies that the resulting affine should yield nearly identical results when read directly from the cube.

Bilinear interpolation is applied to surrounding transformed pixels to provide each new output pixel.

The chipped parameter will be updated to fully reflect the state of this original chip. The state of the chipped parameter dictates the size and the tack sample and line coordinates. Upon return, the corresponding cube sample and line coordinate is updated to the tack sample and line chip coordinate.

As such, note that an identity affine transform will yield identical results to the Chip::Extract method specifying the tack sample and line as the location to extract.

The following example demonstrates how to linearly shift a chip one pixel right and one down.

Chip mychip(35,35);
Cube cube("mycube.cub");
mychip.TackCube(200.0,200.0);
mychip.Load(cube);
Affine shift;
shift.Translate(-1.0,-1.0);
Chip ochip(15,15);
mychip.Extract(ochip, shift);
Parameters
chippedInput/output chip containing the transformed subchip
affineAffine transform to apply to extract subchip

References Isis::Affine::Compute(), Isis::Double, Isis::Buffer::DoubleBuffer(), Isis::Affine::Forward(), Isis::Interpolator::HotLine(), Isis::Interpolator::HotSample(), Isis::Interpolator::Interpolate(), Isis::Buffer::Line(), Isis::Interpolator::Lines(), Lines(), Isis::Null, Isis::Buffer::Sample(), Isis::Interpolator::Samples(), Samples(), Isis::Portal::SetPosition(), SetValue(), Isis::Buffer::size(), TackLine(), TackSample(), Isis::Affine::xp(), and Isis::Affine::yp().

◆ Extract() [2/3]

void Isis::Chip::Extract ( int  samp,
int  line,
Chip chipped 
)

Extract a subchip centered at the designated coordinate.

This method extracts a subchip that is centered at the given sample and line coordinate. All appropriate variables in the given chipped parameter are set appropriately prior to return.

Parameters
sampCenter (tack) sample chip coordinate to extract subchip
lineCenter (tack) line chip coordinate to extract subchip
chippedChip to load the subchip in and return to caller

References Lines(), Isis::Null, Samples(), SetValue(), TackLine(), and TackSample().

◆ Extract() [3/3]

Chip Isis::Chip::Extract ( int  samples,
int  lines,
int  samp,
int  line 
)

Extract a sub-chip from a chip.

Parameters
samplesNumber of samples in the extracted chip (must be less than or equal to "this" chip)
linesNumber of lines in the extracted chip (must be less than or equal to "this" chip)
sampInput chip sample to be placed at output chip tack
lineInput chip line to be placed at output chip tack
Returns
Chip Sub-chip extracted from the chip
Exceptions
Isis::IException::Programmer- Chip extraction invalid

References _FILEINFO_, Isis::Null, SetValue(), TackLine(), TackSample(), and Isis::toString().

Referenced by Isis::InterestOperator::InterestByMeasure(), Isis::InterestOperator::Operate(), Isis::AutoReg::Registration(), and Isis::Gruen::Registration().

◆ FileName()

QString Isis::Chip::FileName ( ) const
inline
Returns
The expanded filename of the cube from which this chip was chipped.

◆ GetReadInterpolator()

Interpolator::interpType Isis::Chip::GetReadInterpolator ( )
inline

Access method that returns the Interpolator Type used for loading a chip.

Returns
const Interpolator::interpType Interpolator used to read data from cube and put it into a chip.
See also
Read()
SetReadInterpolator()
Author
Jeannie Walldren

◆ GetTransform()

const Affine& Isis::Chip::GetTransform ( ) const
inline

Returns the Affine transformation of chip-to-cube indices.

This method returns the affine transform used to load a chip from the same area as a match cube. It also is used to track the tack point line and sample translations from the chip indices to the absolute cube coordiates.

Returns
const Affine& Transform map from chip coordinates to cube coordinates

◆ GetValue() [1/2]

◆ GetValue() [2/2]

double Isis::Chip::GetValue ( int  sample,
int  line 
) const
inline

Get a value from a Chip.

For example,

Chip c(10,5);
cout << c[3,3] << endl;
Parameters
sampleSample position to get (1-based)
lineLine position to get (1-based)
Returns
(double) The value of the chip at the specified line/sample

◆ IsInsideChip()

bool Isis::Chip::IsInsideChip ( double  sample,
double  line 
)
Parameters
sample
line
Returns
bool True if the given sample, line is inside the chip

Referenced by Isis::ChipViewport::cubeToViewport().

◆ IsValid() [1/2]

bool Isis::Chip::IsValid ( double  percentage)

Return if total number of valid pixels in chip meets a specified percentage of the entire chip.

Parameters
percentageThe percentage that the valid pixels percentage must exceed
Returns
bool Returns true if the percentage of valid pixels is greater than the specified percentage, and false if it is not

◆ IsValid() [2/2]

bool Isis::Chip::IsValid ( int  sample,
int  line 
)
inline
Parameters
sampleSample position
lineLine position
Returns
(bool) Whether the value at the given sample, line position is within the valid range

References GetValue().

Referenced by Isis::Gruen::algorithm(), Isis::AutoReg::Register(), and Isis::AutoReg::Registration().

◆ Lines()

◆ Load() [1/3]

void Isis::Chip::Load ( Cube cube,
Chip match,
Cube matchChipCube,
const double  scale = 1.0,
const int  band = 1 
)

Loads cube data into the Chip.

The data will be loaded such that the position set using TackCube method will be put at the center of the chip. The data will be loaded to sub-pixel accuracy using the interpolator indicated using SetReadInterpolator() method. Additionally, the data will be loaded such that it matches the camera and/or projective geometry of a given Chip.

Parameters
cubeThe cube used to put data into the chip
matchMatch the geometry of this chip
matchChipCubeThe cube used to put data into the match chip
scalescale factor (default of 1)
bandBand number to use when loading (default of 1)
Exceptions
Isis::iException::Programmer- Chip cube is not a camera or map projection
Isis::iException::Programmer- Match chip cube is not a camera or map projection
Isis::iException::Programmer- Cannot find enough points to perform Affine transformation.
See also
Read()
SetReadInterpolator()
GetReadInterpolator()

References _FILEINFO_, Isis::IException::append(), Isis::Cube::camera(), CubeLine(), CubeSample(), Isis::Cube::fileName(), Isis::Sensor::HasSurfaceIntersection(), Isis::Projection::IsGood(), Isis::Camera::Line(), Isis::Cube::projection(), Isis::Camera::Sample(), SetChipPosition(), Isis::Camera::SetImage(), Isis::Projection::SetUniversalGround(), Isis::Camera::SetUniversalGround(), Isis::Projection::SetWorld(), TackLine(), TackSample(), Isis::TProjection::UniversalLatitude(), Isis::Sensor::UniversalLatitude(), Isis::TProjection::UniversalLongitude(), Isis::Sensor::UniversalLongitude(), Isis::Projection::WorldX(), and Isis::Projection::WorldY().

◆ Load() [2/3]

void Isis::Chip::Load ( Cube cube,
const Affine affine,
const bool &  keepPoly = true,
const int  band = 1 
)

Load a chip using an Affine transform as provided by caller.

This method will load data from a cube using an established Affine transform as provided by the caller. It is up to the caller to set up the affine appropriately.

For example, the first thing this method will do is set the chip tack point to the transformed cube location by replacing the existing affine transform with the one passed in and then calling SetChipPosition providing the chip tack point as the argument. This establishes which cube pixel is located at the chip tack point.

The data will be loaded to sub-pixel accuracy using the interpolator indicated using SetReadInterpolator() method.

Parameters
cubeCube to load the data from
affineAffine transform to set for chip load/operations
keepPolyIndicates whether clipping polygon should be kept or removed (default of true)
bandBand number to read data from (default of 1)
See also
Read()
SetReadInterpolator()
GetReadInterpolator()

References Isis::Cube::fileName().

◆ Load() [3/3]

void Isis::Chip::Load ( Cube cube,
const double  rotation = 0.0,
const double  scale = 1.0,
const int  band = 1 
)

Load cube data into the Chip.

The data will be loaded such that the position set using TackCube method will be put at the center of the chip. The data will be loaded to sub-pixel accuracy using the interpolator indicated using SetReadInterpolator() method.

Parameters
cubeThe cube used to put data into the chip
rotationrotation in degrees of data about the cube tack point (default of 0)
scalescale factor (default of 1)
bandBand number to use when loading (default of 1)
See also
Read()
SetReadInterpolator()
GetReadInterpolator()

References Isis::Cube::fileName().

Referenced by Isis::ChipViewport::geomChip(), Isis::InterestOperator::InterestByMeasure(), Isis::ChipViewport::nogeomChip(), Isis::InterestOperator::Operate(), Isis::ChipViewport::rotateChip(), Isis::ControlMeasureEditWidget::setLeftMeasure(), Isis::ControlPointEdit::setLeftMeasure(), Isis::ChipViewportsWidget::setPoint(), Isis::ControlMeasureEditWidget::setRightMeasure(), and Isis::ControlPointEdit::setRightMeasure().

◆ operator=()

Chip & Isis::Chip::operator= ( const Chip other)

Copy assignment operator.

Parameters
otherchip to be copied to this
Returns
The chip that was copied from the other

◆ Samples()

◆ SetAllValues()

void Isis::Chip::SetAllValues ( const double &  d)

Single value assignment operator.

Sets the entire chip to a constant

Parameters
dValue to set the chip to

Referenced by Isis::Centroid::select().

◆ SetChipPosition()

void Isis::Chip::SetChipPosition ( const double  sample,
const double  line 
)

Compute the position of the cube given a chip coordinate.

Any rotation or geometric matching done during the Load process will be taken into account. Use CubeSample and CubeLine methods to obtain results. Note the results could be outside of the cube

Parameters
samplechip sample coordinate
linechip line coordinate

Referenced by Isis::InterestOperator::InterestByMeasure(), Isis::ChipViewport::keyPressEvent(), Load(), Isis::ChipViewport::mousePressEvent(), Isis::InterestOperator::Operate(), Isis::ChipViewport::panDown(), Isis::ChipViewport::panLeft(), Isis::ChipViewport::panRight(), Isis::ChipViewport::panUp(), Isis::AutoReg::Register(), Isis::AutoReg::Registration(), Isis::Gruen::Registration(), Isis::ChipViewport::tackLine(), and Isis::ChipViewport::tackSample().

◆ SetClipPolygon()

void Isis::Chip::SetClipPolygon ( const geos::geom::MultiPolygon &  clipPolygon)

Sets the clipping polygon for this chip.

The coordinates must be in (sample,line) order. All Pixel values outside this polygon will be set to Null8. The cubic convolution interpolation is allowed to uses valid pixels outside the clipping area.

Parameters
clipPolygonThe polygons used to clip the chip

Referenced by Isis::InterestOperator::InterestByMeasure(), and Isis::InterestOperator::Operate().

◆ SetCubePosition()

void Isis::Chip::SetCubePosition ( const double  sample,
const double  line 
)

Compute the position of the chip given a cube coordinate.

Any rotation or geometric matching done during the Load process will be taken into account. Use ChipSample and ChipLine methods to obtain results. Note that the results could be outside of the chip.

Parameters
samplechip sample coordinate
linechip line coordinate

Referenced by Isis::ChipViewport::cubeToViewport().

◆ SetReadInterpolator()

void Isis::Chip::SetReadInterpolator ( const Interpolator::interpType  type)
inline

Sets Interpolator Type for loading a chip.

This type is used in the Read() method.

Parameters
typeInterpolator type to be used.
Exceptions
IException::Programmer- Invalid Interpolator Type
See also
Read()
SetReadInterpolator()
Author
Jeannie Walldren

References _FILEINFO_, Isis::Interpolator::BiLinearType, Isis::Interpolator::CubicConvolutionType, Isis::Interpolator::NearestNeighborType, Isis::IException::Programmer, and Isis::toString().

◆ SetSize()

void Isis::Chip::SetSize ( const int  samples,
const int  lines 
)

Change the size of the Chip.

Parameters
samplesnumber of samples in the chip
linesnumber of lines in the chip
Exceptions
Isis::iException::User- Samples and lines must be greater than zero.

References _FILEINFO_, and Isis::toString().

Referenced by Isis::Gruen::Registration(), and Isis::Centroid::select().

◆ SetTransform()

void Isis::Chip::SetTransform ( const Affine affine,
const bool &  keepPoly = true 
)
inline

Sets the internal Affine transform to new translation.

Provides the ability to establish a new affine transformation without overhead of, say, loading the chip with a new translation. The caller also has the option to specify the disposition of an established polygon.

Parameters
affineNew affine tranform to set for this chip
keepPolyIndicates whether an existing polygon clipper should be kept (default of true)

◆ SetValidRange()

void Isis::Chip::SetValidRange ( const double  minimum = Isis::ValidMinimum,
const double  maximum = Isis::ValidMaximum 
)

Set the valid range of data in the chip.

If never called all data in the chip is consider valid (other than special pixels).

Parameters
minimumminimum valid pixel value (default of Isis::ValidMinimum)
maximummaximum valid pixel value (default of Isis::ValidMaximum)
Exceptions
Isis::iException::Programmer- First parameter must be smaller than the second.

References _FILEINFO_, and Isis::toString().

◆ SetValue()

void Isis::Chip::SetValue ( int  sample,
int  line,
const double &  value 
)
inline

Sets a value in the chip.

Parameters
sampleSample position to load (1-based)
lineLine position to load (1-based)
valueValue to set

Referenced by Isis::CentroidApolloPan::elipticalReduction(), Isis::Selection::elipticalReduction(), Extract(), Isis::AutoReg::Reduce(), Isis::Centroid::select(), and Isis::AutoReg::SetSubpixelPosition().

◆ Statistics()

Isis::Statistics * Isis::Chip::Statistics ( )

Returns a statistics object of the current data in the chip.

The caller takes ownership of the returned instance.

Returns
Isis::Statistics* Statistics of the data in the chip

References Isis::Statistics::AddData(), and Isis::Statistics::SetValidRange().

◆ TackCube()

void Isis::Chip::TackCube ( const double  cubeSample,
const double  cubeLine 
)

◆ TackLine()

int Isis::Chip::TackLine ( ) const
inline

This method returns a chip's fixed tack line; the middle of the chip.

It is a chip coordinate, not a cube coordinate. For example, a chip with 5 lines will return 3, the middle pixel. A chip with 4 lines will return 2.

Returns
The fixed tack line of the chip.

Referenced by Isis::Gruen::algorithm(), Extract(), Isis::ChipViewport::keyPressEvent(), Load(), Isis::ChipViewport::panDown(), Isis::ChipViewport::panLeft(), Isis::ChipViewport::panRight(), Isis::ChipViewport::panUp(), Isis::AutoReg::Register(), Isis::Gruen::Registration(), Isis::ChipViewport::tackLine(), and Isis::ChipViewport::tackSample().

◆ TackSample()

int Isis::Chip::TackSample ( ) const
inline

This method returns a chip's fixed tack sample; the middle of the chip.

It is a chip coordinate, not a cube coordinate. For example, a chip with 5 samples will return 3, the middle pixel. A chip with 4 samples will return 2.

Returns
The fixed tack sample of the chip.

Referenced by Isis::Gruen::algorithm(), Extract(), Isis::ChipViewport::keyPressEvent(), Load(), Isis::ChipViewport::panDown(), Isis::ChipViewport::panLeft(), Isis::ChipViewport::panRight(), Isis::ChipViewport::panUp(), Isis::AutoReg::Register(), Isis::Gruen::Registration(), Isis::ChipViewport::tackLine(), and Isis::ChipViewport::tackSample().

◆ Write()

void Isis::Chip::Write ( const QString &  filename)

The documentation for this class was generated from the following files:
Isis::Chip::Chip
Chip()
Constructs a Chip.
Definition: Chip.cpp:35