Isis 3 Programmer Reference
|
Workhorse of stereo matcher. More...
#include <SmtkMatcher.h>
Public Member Functions | |
SmtkMatcher () | |
Construct default matcher. More... | |
SmtkMatcher (const QString ®def) | |
Construct with Gruen definintions file. More... | |
SmtkMatcher (const QString ®def, 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 ®def) |
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... | |
Chip * | PatternChip () const |
Return pattern chip. More... | |
Chip * | SearchChip () const |
Return search chip. More... | |
Chip * | FitChip () 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 | |
SmtkMatcher & | operator= (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... | |
Camera & | lhCamera () |
Camera & | rhCamera () |
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 | |
Cube * | m_lhCube |
Cube * | m_rhCube |
QSharedPointer< Gruen > | m_gruen |
BigInt | m_offImage |
BigInt | m_spiceErr |
bool | m_useAutoReg |
const gsl_rng_type * | T |
gsl_rng * | r |
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.
Definition at line 45 of file SmtkMatcher.h.
Isis::SmtkMatcher::SmtkMatcher | ( | ) |
Construct default matcher.
Definition at line 25 of file SmtkMatcher.cpp.
References randomNumberSetup().
Isis::SmtkMatcher::SmtkMatcher | ( | const QString & | regdef | ) |
Construct with Gruen definintions file.
Definition at line 32 of file SmtkMatcher.cpp.
References randomNumberSetup(), and setGruenDef().
Construct with Gruen definintions file and camera objects
Definition at line 43 of file SmtkMatcher.cpp.
References randomNumberSetup(), and setGruenDef().
Isis::SmtkMatcher::~SmtkMatcher | ( | ) |
Free random number generator in destructor.
Definition at line 54 of file SmtkMatcher.cpp.
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.
point | Chip center location |
newpoint | New point to clone to via application of affine transform |
affine | The affine transform to apply to get new (right) clone point |
Definition at line 467 of file SmtkMatcher.cpp.
References Isis::SmtkPoint::getAffine(), Isis::SmtkPoint::getLeft(), Isis::AffineRadio::getPoint(), Isis::SmtkPoint::getRight(), and inCube().
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.
left | Left point |
right | Right point |
Definition at line 427 of file SmtkMatcher.cpp.
References getLatLon(), Isis::Coordinate::isValid(), and Isis::Analysis::setZeroState().
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
stack | Stack to find the best value in |
seedsample | The point within the exponential distribution of interest |
minEV | Minimum occuring eigen value |
maxEV | Maximum occuring eigen value |
Definition at line 182 of file SmtkMatcher.cpp.
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.
stack | Stack to find the best point in. |
Definition at line 149 of file SmtkMatcher.cpp.
|
inline |
|
private |
Compute latitude, longitude from line,sample.
camera | Camera object to compute lat/lon coordinates in |
pnt | Line/Sample coordinate of point to compute |
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().
|
private |
Compute line,sample from latitude, longitude.
camera | Camera object to compute lat/lon coordinates in |
pnt | Latitude/longitude coordinate to compute |
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().
|
private |
Determines if the line/sample is within physical cube boundaries.
camera | Camera to determine dimensions |
sample | Sample location |
line | Line location |
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().
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.
pnt | Line/Sample coordinate in left image |
Definition at line 101 of file SmtkMatcher.cpp.
References getLatLon(), getLineSample(), Isis::Coordinate::isValid(), and validate().
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.
spnt | SmtkPoint to check for valid coordiantes |
Definition at line 220 of file SmtkMatcher.cpp.
References Isis::SmtkPoint::getLeft(), Isis::SmtkPoint::getRight(), inCube(), and Isis::SmtkPoint::isValid().
|
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 (
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.
left | Left point with geometry |
right | RIght point with geometry |
gruen | Gruen algorithm to use to register points |
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().
|
inline |
|
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.
Definition at line 496 of file SmtkMatcher.cpp.
References Isis::GSL::GSLUtility::getInstance().
Referenced by SmtkMatcher().
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().
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.
lpg | |
rpg | |
affrad |
Definition at line 333 of file SmtkMatcher.cpp.
References getLatLon(), getLineSample(), Isis::Coordinate::isValid(), makeRegisteredPoint(), Isis::IException::Programmer, and validate().
SmtkPoint Isis::SmtkMatcher::Register | ( | const PointPair & | pnts, |
const AffineRadio & | affrad = AffineRadio() |
||
) |
Register a defined left/right point pair.
pnts | Points to register |
affrad | Affine/Radiometric parameters to use |
Definition at line 265 of file SmtkMatcher.cpp.
References Register().
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.
spnt | SmtkPoint to register |
affrad | Affine/Radiometrics to use for registration |
Definition at line 294 of file SmtkMatcher.cpp.
References Isis::SmtkPoint::getLeft(), Isis::SmtkPoint::getRight(), Isis::SmtkPoint::isRegistered(), and Register().
|
inline |
Return Gruen registration statistics.
Definition at line 101 of file SmtkMatcher.h.
|
inline |
Return Gruen template parameters.
Definition at line 99 of file SmtkMatcher.h.
|
inline |
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.
Definition at line 78 of file SmtkMatcher.cpp.
Referenced by SmtkMatcher().
Assign cubes for matching.
Definition at line 60 of file SmtkMatcher.cpp.
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.
pattern | Set the file pattern of the output cube search chips. |
Definition at line 132 of file SmtkMatcher.cpp.
References validate().
|
private |
Validates the state of the Camera and Gruen algoritm.
Basically ensures all the pointers are initialized.
throwError | Throws an exception if user sets this to true. Otherwise status can be determined from the return value. |
Definition at line 517 of file SmtkMatcher.cpp.
References Isis::IException::Programmer.
Referenced by FitChip(), isValid(), PatternChip(), Register(), SearchChip(), and setWriteSubsearchChipPattern().