31 #include <QSharedPointer> 43 m_offImage(0), m_spiceErr(0),
61 Cube *rhCube) : m_lhCube(lhCube),
63 m_gruen(0), m_offImage(0),
151 m_gruen->WriteSubsearchChips(fileptrn);
167 SmtkQStackIter best(stack.begin()), current(stack.begin());
168 while ( current != stack.end() ) {
169 if (current.value().GoodnessOfFit() < best.value().GoodnessOfFit() ) {
200 const double &seedsample,
202 const double &maxEV) {
204 if (stack.isEmpty())
return (stack.end());
205 SmtkQStackIter best(stack.begin()), current(stack.begin());
208 double randNum = gsl_rng_uniform (r);
209 double t1 = -std::log(1.0 - randNum *
210 (1.0 - std::exp(-seedsample)))/seedsample;
211 double pt = minEV + t1*(maxEV-minEV);
212 double best_ev(DBL_MAX);
213 while ( current != stack.end() ) {
214 double test_ev(std::fabs(current.value().GoodnessOfFit()-pt));
215 if ( test_ev < best_ev) {
241 std::cout <<
"Point status is invalid!\n";
247 std::cout <<
"Left point (" << spnt.
getLeft().getLine() <<
"," 248 << spnt.
getLeft().getSample() <<
") is invalid!\n";
254 std::cout <<
"Right point (" << spnt.
getRight().getLine() <<
"," 255 << spnt.
getRight().getSample() <<
") is invalid!\n";
320 return (
Register(left, right, affrad));
359 if (!lpg.getPoint().
isValid()) {
360 QString mess =
"Left point is not defined which is required";
374 if (!left.isValid()) {
397 if (!right.isValid()) {
404 m_gruen->PatternChip()->TackCube(lpnt.getSample(), lpnt.getLine());
405 m_gruen->PatternChip()->Load(*m_lhCube);
406 m_gruen->SearchChip()->TackCube(rpnt.getSample(), rpnt.getLine());
407 m_gruen->SearchChip()->Load(*m_rhCube, *m_gruen->PatternChip(),
416 m_gruen->setAffineRadio(affrad);
464 spnt.m_isValid =
true;
495 mpt.m_point = cpoint;
499 spnt.m_registered =
false;
500 spnt.m_isValid =
inCube(lhCamera(), left) &&
inCube(rhCamera(), right);
517 r = gsl_rng_alloc (T);
536 if (!m_lhCube) isGood =
false;
537 if (!m_rhCube) isGood =
false;
538 if (!m_gruen.data()) isGood =
false;
539 if ((!isGood) && throwError) {
540 QString mess =
"Images/match algorithm not initialized!";
558 if (!pnt.
isValid())
return (
false);
559 if ( (pnt.getSample() < 0.5) || (pnt.getLine() < 0.5) )
return false;
560 if ( (pnt.getSample() > (camera.
Samples() + 0.5)) ||
561 (pnt.getLine() > (camera.
Lines() + 0.5)) ) {
583 if (
inCube(camera, pnt)) {
584 if ( camera.
SetImage(pnt.getSample(), pnt.getLine()) ) {
643 PointPair(left.getGeometry(), right.getGeometry())));
661 if ( !rpoint.isValid() ) {
663 spnt.m_isValid =
false;
667 double dist = (rcorr - right.getPoint()).getDistance();
670 spnt.m_isValid =
false;
673 spnt.m_isValid = match.isValid();
Success registering to sub-pixel accuracy.
bool isValid() const
Indicates the smtk portion of the point is valid.
void setZeroState()
Resets eigenvalues to 0.
SmtkPoint Clone(const SmtkPoint &point, const Coordinate &left)
Clone a point set from a nearby (left image) point and Gruen affine.
Coordinate getPoint(const Coordinate &location) const
Applies the affine transfrom to a point and returns result.
SmtkQStackIter FindExpDistEV(SmtkQStack &stack, const double &seedsample, const double &minEV, const double &maxEV)
Find the best eigen value using exponential distribution formula.
Define a generic Y/X container.
double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
bool validate(const bool &throwError=true) const
Validates the state of the Camera and Gruen algoritm.
void setImages(Cube *lhImage, Cube *rhImage)
Assign cubes for matching.
SmtkPoint Create(const Coordinate &left, const Coordinate &right)
Create a valid, unregistered SmtkPoint.
Define a point set of left, right and geometry at that location.
SmtkMatcher()
Construct default matcher.
const Coordinate & getRight() const
Returns the registered right coordinate.
bool InCube()
This returns true if the current Sample() or Line() value is outside of the cube (meaning the point m...
static GSLUtility * getInstance()
Return a reference to the GSL (singleton) object.
AutoReg::RegisterStatus Register()
Walk the pattern chip through the search chip to find the best registration.
Coordinate getLineSample(Camera &camera, const Coordinate &geom)
Compute line,sample from latitude, longitude.
Container for a point and its geometry.
This error is for when a programmer made an API call that was illegal.
void setLatLon(const double &latitude, const double &longitude)
Use Latitude/Longitude interface.
bool isRegistered() const
Returns registration status.
const AffineRadio & getAffine() const
Returns the affine transform and radiometic results.
SmtkPoint makeRegisteredPoint(const PointGeometry &left, const PointGeometry &right, Gruen *gruen)
Create an SmtkPoint from Gruen match result.
void setGruenDef(const QString ®def)
Initialize Gruen algorithm with definitions in Pvl file provided.
double CubeSample() const
Return the search chip cube sample that best matched.
double getSpiceConstraint() const
Returns the SPICE tolerance constraint as read from config file.
bool SetUniversalGround(const double latitude, const double longitude)
Sets the lat/lon values to get the sample/line values.
bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
bool inCube(const Camera &camera, const Coordinate &point) const
Determines if the line/sample is within physical cube boundaries.
MatchPoint getLastMatch() const
Returns the register state of the last successful Gruen match.
#define _FILEINFO_
Macro for the filename and line number.
const Coordinate & getLeft() const
Returns the left point.
double Sample()
Returns the current sample number.
Coordinate getLatLon(Camera &camera, const Coordinate &pnt)
Compute latitude, longitude from line,sample.
void setLineSamp(const double &line, const double &sample)
Use the Line/Sample interface.
double CubeLine() const
Return the search chip cube line that best matched.
bool isValid() const
Check for goodness.
Container for cube-like labels.
double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
Container for affine and radiometric parameters.
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...
Structure containing comprehensive registration info/results.
Gruen pattern matching algorithm.
SmtkQStackIter FindSmallestEV(SmtkQStack &stack)
Find the smallest eigen value on the given stack.
void setWriteSubsearchChipPattern(const QString &fileptrn="SmtkMatcher")
Set file pattern for output subsearch chips.
double Line()
Returns the current line number.
int Lines() const
Returns the number of lines in the image.
int Samples() const
Returns the number of samples in the image.
Namespace for ISIS/Bullet specific routines.
~SmtkMatcher()
Free random number generator in destructor.
void randomNumberSetup()
Initialize the random number generator.
Container for SMTK match points
bool isValid(const Coordinate &pnt)
Determine if a point is valid in both left/right images.
IO Handler for Isis Cubes.