Isis 3 Programmer Reference
Isis::SmtkMatcher Class Reference

Workhorse of stereo matcher. More...

#include <SmtkMatcher.h>

Collaboration diagram for Isis::SmtkMatcher:
Collaboration graph

Public Member Functions

 SmtkMatcher ()
 Construct default matcher. More...
 
 SmtkMatcher (const QString &regdef)
 Construct with Gruen definintions file. More...
 
 SmtkMatcher (const QString &regdef, Cube *lhImage, Cube *rhImage)
 Construct with Gruen definintions file and camera objects
More...
 
 SmtkMatcher (Cube *lhImage, Cube *rhImage)
 
 ~SmtkMatcher ()
 Free random number generator in destructor. More...
 
void setImages (Cube *lhImage, Cube *rhImage)
 Assign cubes for matching. More...
 
void setGruenDef (const QString &regdef)
 Initialize Gruen algorithm with definitions in Pvl file provided. More...
 
bool isValid (const Coordinate &pnt)
 Determine if a point is valid in both left/right images. More...
 
bool isValid (const SmtkPoint &spnt)
 Valid a point prior to insertion. More...
 
ChipPatternChip () const
 Return pattern chip. More...
 
ChipSearchChip () const
 Return search chip. More...
 
ChipFitChip () const
 Returns the fit chip. More...
 
void setWriteSubsearchChipPattern (const QString &fileptrn="SmtkMatcher")
 Set file pattern for output subsearch chips. More...
 
SmtkQStackIter FindSmallestEV (SmtkQStack &stack)
 Find the smallest eigen value on the given stack. More...
 
SmtkQStackIter FindExpDistEV (SmtkQStack &stack, const double &seedsample, const double &minEV, const double &maxEV)
 Find the best eigen value using exponential distribution formula. More...
 
SmtkPoint Register (const Coordinate &lpnt, const AffineRadio &affrad=AffineRadio())
 This method takes a sample, line from the left-hand image and tries to find the matching point in the right-hand image. More...
 
SmtkPoint Register (const PointPair &pnts, const AffineRadio &affrad=AffineRadio())
 Register a defined left/right point pair. More...
 
SmtkPoint Register (const SmtkPoint &spnt, const AffineRadio &affrad=AffineRadio())
 Register an SmtkPoint. More...
 
SmtkPoint Register (const PointGeometry &lpg, const PointGeometry &rpg, const AffineRadio &affrad=AffineRadio())
 Applies registration of two points. More...
 
SmtkPoint Create (const Coordinate &left, const Coordinate &right)
 Create a valid, unregistered SmtkPoint. More...
 
SmtkPoint Clone (const SmtkPoint &point, const Coordinate &left)
 Clone a point set from a nearby (left image) point and Gruen affine. More...
 
BigInt OffImageErrorCount () const
 
BigInt SpiceErrorCount () const
 
PvlGroup RegTemplate ()
 Return Gruen template parameters. More...
 
Pvl RegistrationStatistics ()
 Return Gruen registration statistics. More...
 

Private Member Functions

SmtkMatcheroperator= (const SmtkMatcher &matcher)
 
 SmtkMatcher (const SmtkMatcher &matcher)
 
void randomNumberSetup ()
 Initialize the random number generator. More...
 
bool validate (const bool &throwError=true) const
 Validates the state of the Camera and Gruen algoritm. More...
 
CameralhCamera ()
 
CamerarhCamera ()
 
Coordinate getLineSample (Camera &camera, const Coordinate &geom)
 Compute line,sample from latitude, longitude. More...
 
Coordinate getLatLon (Camera &camera, const Coordinate &pnt)
 Compute latitude, longitude from line,sample. More...
 
bool inCube (const Camera &camera, const Coordinate &point) const
 Determines if the line/sample is within physical cube boundaries. More...
 
SmtkPoint makeRegisteredPoint (const PointGeometry &left, const PointGeometry &right, Gruen *gruen)
 Create an SmtkPoint from Gruen match result. More...
 

Private Attributes

Cubem_lhCube
 
Cubem_rhCube
 
QSharedPointer< Gruenm_gruen
 
BigInt m_offImage
 
BigInt m_spiceErr
 
bool m_useAutoReg
 
const gsl_rng_type * T
 
gsl_rng * r
 

Detailed Description

Workhorse of stereo matcher.

This class provides stereo matching functionality to the SMTK toolkit. It registers points, clones them by adjusting parameters to nearby point locations and manages point selection processes.

The Gruen algorithm is initialized here and maintained for use in the stereo matching process.

Author
2011-05-28 Kris Becker
History:
2012-12-20 Debbie A. Cook - Removed unused Projection.h References #775.
History:
2017-08-18 Summer Stapleton, Ian Humphrey, Tyler Wilson - Changed auto_ptr reference to QSharedPointer so this class compiles under C++14.
References #4809.

Definition at line 45 of file SmtkMatcher.h.

Constructor & Destructor Documentation

◆ SmtkMatcher() [1/3]

Isis::SmtkMatcher::SmtkMatcher ( )

Construct default matcher.

Definition at line 25 of file SmtkMatcher.cpp.

References randomNumberSetup().

◆ SmtkMatcher() [2/3]

Isis::SmtkMatcher::SmtkMatcher ( const QString &  regdef)

Construct with Gruen definintions file.

Definition at line 32 of file SmtkMatcher.cpp.

References randomNumberSetup(), and setGruenDef().

◆ SmtkMatcher() [3/3]

Isis::SmtkMatcher::SmtkMatcher ( const QString &  regdef,
Cube lhImage,
Cube rhImage 
)

Construct with Gruen definintions file and camera objects

Definition at line 43 of file SmtkMatcher.cpp.

References randomNumberSetup(), and setGruenDef().

◆ ~SmtkMatcher()

Isis::SmtkMatcher::~SmtkMatcher ( )

Free random number generator in destructor.

Definition at line 54 of file SmtkMatcher.cpp.

Member Function Documentation

◆ Clone()

SmtkPoint Isis::SmtkMatcher::Clone ( const SmtkPoint point,
const Coordinate left 
)

Clone a point set from a nearby (left image) point and Gruen affine.

This method is used to clone a PointPair from a new point and an Affine transform. Assume the left point in the set is at the center of the box and compute the offset of the point using the Affine. Apply it the right point.

Parameters
pointChip center location
newpointNew point to clone to via application of affine transform
affineThe affine transform to apply to get new (right) clone point
Returns
PointPair The clone point from the original

Definition at line 467 of file SmtkMatcher.cpp.

References Isis::SmtkPoint::getAffine(), Isis::SmtkPoint::getLeft(), Isis::AffineRadio::getPoint(), Isis::SmtkPoint::getRight(), and inCube().

◆ Create()

SmtkPoint Isis::SmtkMatcher::Create ( const Coordinate left,
const Coordinate right 
)

Create a valid, unregistered SmtkPoint.

This method is typically used to create a point from a control point network. The point is deemed registered, but not necessarily by Gruen. Therefore, it is set as unregistered.

The left and right coordinates are deemed valid and geometry for both points is computed and verified (either the points are off image or does not map to a lat/long).

The points is set as valid and when Register() is called it will likely be run through the Gruen algorithm.

In essence, a valid, but unregistered SmtkPoint is returned if all the line/sample coordinates and geometry check out.

Author
Kris Becker - 5/30/2011
Parameters
leftLeft point
rightRight point
Returns
SmtkPoint

Definition at line 427 of file SmtkMatcher.cpp.

References getLatLon(), Isis::Coordinate::isValid(), and Isis::Analysis::setZeroState().

◆ FindExpDistEV()

SmtkQStackIter Isis::SmtkMatcher::FindExpDistEV ( SmtkQStack stack,
const double &  seedsample,
const double &  minEV,
const double &  maxEV 
)

Find the best eigen value using exponential distribution formula.

This method has the same objective as FindSmallestEV, but uses a different test to find the best value. It uses s randomly generated value within an exponential distribution from the minimum to maximum occuring eigen value.

Upon each call to this routine, the random seed is regenerated.

NOTE: This implementation differs somewhat from the ISIS2 version in that the value of the computed eigenvalue is used as the best eigenvalue. This implementation produced better distributoion of points

Parameters
stackStack to find the best value in
seedsampleThe point within the exponential distribution of interest
minEVMinimum occuring eigen value
maxEVMaximum occuring eigen value
Returns
SmtkQStackIter Stack interator

Definition at line 182 of file SmtkMatcher.cpp.

◆ FindSmallestEV()

SmtkQStackIter Isis::SmtkMatcher::FindSmallestEV ( SmtkQStack stack)

Find the smallest eigen value on the given stack.

This static method iterates through a stack to find the best (smallest) eigen value as computed by the Gruen registration algorithm. If the stack is empty or if for some unapparent reason why the best point cannot be found, stack.end() is returned.

Parameters
stackStack to find the best point in.
Returns
SmtkQStackIter Returns an iterator with the best value

Definition at line 149 of file SmtkMatcher.cpp.

◆ FitChip()

Chip* Isis::SmtkMatcher::FitChip ( ) const
inline

Returns the fit chip.

Definition at line 72 of file SmtkMatcher.h.

References validate().

◆ getLatLon()

Coordinate Isis::SmtkMatcher::getLatLon ( Camera camera,
const Coordinate pnt 
)
private

Compute latitude, longitude from line,sample.

Author
Kris Becker - 5/23/2011
Parameters
cameraCamera object to compute lat/lon coordinates in
pntLine/Sample coordinate of point to compute
Returns
Coordinate Returns a latitude/longitude pair of point

Definition at line 562 of file SmtkMatcher.cpp.

References inCube(), Isis::Coordinate::isValid(), Isis::Camera::SetImage(), Isis::Coordinate::setLatLon(), Isis::Sensor::UniversalLatitude(), and Isis::Sensor::UniversalLongitude().

Referenced by Create(), isValid(), makeRegisteredPoint(), and Register().

◆ getLineSample()

Coordinate Isis::SmtkMatcher::getLineSample ( Camera camera,
const Coordinate geom 
)
private

Compute line,sample from latitude, longitude.

Author
Kris Becker - 5/23/2011
Parameters
cameraCamera object to compute lat/lon coordinates in
pntLatitude/longitude coordinate to compute
Returns
Coordinate Returns a line/sample pair of point

Definition at line 587 of file SmtkMatcher.cpp.

References Isis::Camera::InCube(), Isis::Coordinate::isValid(), Isis::Camera::Line(), Isis::Camera::Sample(), Isis::Coordinate::setLineSamp(), and Isis::Camera::SetUniversalGround().

Referenced by isValid(), and Register().

◆ inCube()

bool Isis::SmtkMatcher::inCube ( const Camera camera,
const Coordinate pnt 
) const
private

Determines if the line/sample is within physical cube boundaries.

Author
Kris Becker - 5/1/2011
Parameters
cameraCamera to determine dimensions
sampleSample location
lineLine location
Returns
bool

Definition at line 540 of file SmtkMatcher.cpp.

References Isis::Coordinate::isValid(), Isis::Camera::Lines(), and Isis::Camera::Samples().

Referenced by Clone(), getLatLon(), and isValid().

◆ isValid() [1/2]

bool Isis::SmtkMatcher::isValid ( const Coordinate pnt)

Determine if a point is valid in both left/right images.

This method accepts a point from the left hand image and determines if it maps to a valid lat/lon coordinate in the left image. It then takes the lat/lon from the left and determines if it maps to a valid line/sample int the right image.

Both images must have cameras associated with them or an exception is thrown.

Author
kbecker (5/25/2011)
Parameters
pntLine/Sample coordinate in left image
Returns
bool True if valid in both images, otherwise false

Definition at line 101 of file SmtkMatcher.cpp.

References getLatLon(), getLineSample(), Isis::Coordinate::isValid(), and validate().

◆ isValid() [2/2]

bool Isis::SmtkMatcher::isValid ( const SmtkPoint spnt)

Valid a point prior to insertion.

This method can be used to valid a point prior to adding it to a point stack. It is a final validation check and should not be used in production but used to debug.

Author
kbecker (6/2/2011)
Parameters
spntSmtkPoint to check for valid coordiantes
Returns
bool True if valid, false if not

Definition at line 220 of file SmtkMatcher.cpp.

References Isis::SmtkPoint::getLeft(), Isis::SmtkPoint::getRight(), inCube(), and Isis::SmtkPoint::isValid().

◆ makeRegisteredPoint()

SmtkPoint Isis::SmtkMatcher::makeRegisteredPoint ( const PointGeometry left,
const PointGeometry right,
Gruen gruen 
)
private

Create an SmtkPoint from Gruen match result.

This method applies the Gruen registration to the points as provided. It assumes the points have been already set up in the gruen algorithm (

See also
Register()) and simply calls the Gruen::RegisterI() function.

The result is the transformed into a SmtkPoint base upon the result of the registration. The status of the point is set to reflect the registration processing result.

Author
Kris Becker - 5/26/2011
Parameters
leftLeft point with geometry
rightRIght point with geometry
gruenGruen algorithm to use to register points
Returns
SmtkPoint

Definition at line 620 of file SmtkMatcher.cpp.

References Isis::AutoReg::CubeLine(), Isis::AutoReg::CubeSample(), Isis::Gruen::getLastMatch(), getLatLon(), Isis::Gruen::getSpiceConstraint(), Isis::AutoReg::Register(), and Isis::AutoReg::SuccessSubPixel.

Referenced by Register().

◆ PatternChip()

Chip* Isis::SmtkMatcher::PatternChip ( ) const
inline

Return pattern chip.

Definition at line 60 of file SmtkMatcher.h.

References validate().

◆ randomNumberSetup()

void Isis::SmtkMatcher::randomNumberSetup ( )
private

Initialize the random number generator.

This randome number generator uses the GSL version. It can be set using envirnment variables. Please see the documenation at the GSL site http://www.gnu.org/software/gsl/manual/html_node/Random-Number-Generation.html.

Author
kbecker (6/3/2011)

Definition at line 496 of file SmtkMatcher.cpp.

References Isis::GSL::GSLUtility::getInstance().

Referenced by SmtkMatcher().

◆ Register() [1/4]

SmtkPoint Isis::SmtkMatcher::Register ( const Coordinate lpnt,
const AffineRadio affrad = AffineRadio() 
)

This method takes a sample, line from the left-hand image and tries to find the matching point in the right-hand image.

Definition at line 250 of file SmtkMatcher.cpp.

Referenced by Register().

◆ Register() [2/4]

SmtkPoint Isis::SmtkMatcher::Register ( const PointGeometry lpg,
const PointGeometry rpg,
const AffineRadio affrad = AffineRadio() 
)

Applies registration of two points.

This method applies the registration of a left and right point set. The points sets may only have the left point defined. This method determines the valid geometry of the left point. If the right point is not defined, it uses the left geometry to determine the right point to register the left point with. If the right point is defined, it verifies the point has valid geometry mapping in the right image. All points and geometry must fall within the boundaries of the image and be valid or the point is deemed invalid.

Once the points is validated, registration is applied to the two points using the left point as truth (or the pattern chip) and the right point (search chip) is loaded according to the geometry of the left chip. An affine transform is immediately applied in the Gruen algorithm to apply the user supplied state of the affine and radiometric parameters.

Author
Kris Becker - 6/4/2011
Parameters
lpg
rpg
affrad
Returns
SmtkPoint

Definition at line 333 of file SmtkMatcher.cpp.

References getLatLon(), getLineSample(), Isis::Coordinate::isValid(), makeRegisteredPoint(), Isis::IException::Programmer, and validate().

◆ Register() [3/4]

SmtkPoint Isis::SmtkMatcher::Register ( const PointPair pnts,
const AffineRadio affrad = AffineRadio() 
)

Register a defined left/right point pair.

Author
Kris Becker - 5/30/2011
Parameters
pntsPoints to register
affradAffine/Radiometric parameters to use
Returns
SmtkPoint Result of point registration

Definition at line 265 of file SmtkMatcher.cpp.

References Register().

◆ Register() [4/4]

SmtkPoint Isis::SmtkMatcher::Register ( const SmtkPoint spnt,
const AffineRadio affrad = AffineRadio() 
)

Register an SmtkPoint.

This method will register an established SmtkPoint. It will determine what parts of the point need to be completed in order for the registration to be valid. For instance, a default initialization of an SmtkPoint may only requre the left point to be defined. Or both points are defined but it has been registered but cloned (see Clone()).

It the point is deemed registered it will simply be returned as is without further processing. So to register a point ensure it the m_register flag is set to false.

Author
Kris Becker - 5/30/2011
Parameters
spntSmtkPoint to register
affradAffine/Radiometrics to use for registration
Returns
SmtkPoint A registered point. Test for validity on return to evaluate success.

Definition at line 294 of file SmtkMatcher.cpp.

References Isis::SmtkPoint::getLeft(), Isis::SmtkPoint::getRight(), Isis::SmtkPoint::isRegistered(), and Register().

◆ RegistrationStatistics()

Pvl Isis::SmtkMatcher::RegistrationStatistics ( )
inline

Return Gruen registration statistics.

Definition at line 101 of file SmtkMatcher.h.

◆ RegTemplate()

PvlGroup Isis::SmtkMatcher::RegTemplate ( )
inline

Return Gruen template parameters.

Definition at line 99 of file SmtkMatcher.h.

◆ SearchChip()

Chip* Isis::SmtkMatcher::SearchChip ( ) const
inline

Return search chip.

Definition at line 66 of file SmtkMatcher.h.

References validate().

◆ setGruenDef()

void Isis::SmtkMatcher::setGruenDef ( const QString &  regdef)

Initialize Gruen algorithm with definitions in Pvl file provided.

This method will initialize the Gruen algorithm with a standard AutoReg definitions file. It is re-entrant in that should an existing Gruen object be present, it is freed and replaced by the one resulting from the instantion with the regdef file provided.

Author
Kris Becker - 5/26/2011
Parameters
regdefGruen definitions Pvl file

Definition at line 78 of file SmtkMatcher.cpp.

Referenced by SmtkMatcher().

◆ setImages()

void Isis::SmtkMatcher::setImages ( Cube lhImage,
Cube rhImage 
)

Assign cubes for matching.

Definition at line 60 of file SmtkMatcher.cpp.

◆ setWriteSubsearchChipPattern()

void Isis::SmtkMatcher::setWriteSubsearchChipPattern ( const QString &  fileptrn = "SmtkMatcher")

Set file pattern for output subsearch chips.

This method should be used to set the output subsearch chip file pattern that will be used to write the transformed chip at each Gruen iteration. This is handy to test the pattern chip with the Gruen algorithm search chip. A chip will be generated for each search chip that is transformed for the current iteration.

Note this pattern is only validate for the next call to Register(). It will be reset so that chips are not automatically written for every call to Register().

The pattern can be complete directory path and a file pattern. See Gruen for a complete description.

Author
kbecker (9/15/2011)
Parameters
patternSet the file pattern of the output cube search chips.

Definition at line 132 of file SmtkMatcher.cpp.

References validate().

◆ validate()

bool Isis::SmtkMatcher::validate ( const bool &  throwError = true) const
private

Validates the state of the Camera and Gruen algoritm.

Basically ensures all the pointers are initialized.

Author
Kris Becker - 5/1/2011
Parameters
throwErrorThrows an exception if user sets this to true. Otherwise status can be determined from the return value.
Returns
bool If throwError is not set, this will return status. throwError will cause an exception instead if true.

Definition at line 517 of file SmtkMatcher.cpp.

References Isis::IException::Programmer.

Referenced by FitChip(), isValid(), PatternChip(), Register(), SearchChip(), and setWriteSubsearchChipPattern().


The documentation for this class was generated from the following files: