Isis 3 Programmer Reference
SmtkMatcher.h
1 #ifndef SmtkMatcher_h
2 #define SmtkMatcher_h
3 
9 /* SPDX-License-Identifier: CC0-1.0 */
10 
11 #include <memory>
12 
13 
14 #include <QSharedPointer>
15 #include "SmtkStack.h"
16 #include "Gruen.h"
17 #include "SmtkPoint.h"
18 
19 #include "GSLUtility.h"
20 #include <gsl/gsl_rng.h>
21 
22 
23 namespace Isis {
24 
45 class SmtkMatcher {
46  public:
47  SmtkMatcher();
48  SmtkMatcher(const QString &regdef);
49  SmtkMatcher(const QString &regdef, Cube *lhImage, Cube *rhImage);
50  SmtkMatcher(Cube *lhImage, Cube *rhImage);
51  ~SmtkMatcher();
52 
53  void setImages(Cube *lhImage, Cube *rhImage);
54  void setGruenDef(const QString &regdef);
55 
56  bool isValid(const Coordinate &pnt);
57  bool isValid(const SmtkPoint &spnt);
58 
60  Chip *PatternChip() const {
61  validate();
62  return (m_gruen->PatternChip());
63  }
64 
66  Chip *SearchChip() const {
67  validate();
68  return (m_gruen->SearchChip());
69  }
70 
72  Chip *FitChip() const {
73  validate();
74  return (m_gruen->FitChip());
75  }
76 
77  void setWriteSubsearchChipPattern(const QString &fileptrn = "SmtkMatcher");
78 
79  SmtkQStackIter FindSmallestEV(SmtkQStack &stack);
80  SmtkQStackIter FindExpDistEV(SmtkQStack &stack, const double &seedsample,
81  const double &minEV, const double &maxEV);
82 
83  SmtkPoint Register(const Coordinate &lpnt,
84  const AffineRadio &affrad = AffineRadio());
85  SmtkPoint Register(const PointPair &pnts,
86  const AffineRadio &affrad = AffineRadio());
87  SmtkPoint Register(const SmtkPoint &spnt,
88  const AffineRadio &affrad = AffineRadio());
89  SmtkPoint Register(const PointGeometry &lpg, const PointGeometry &rpg,
90  const AffineRadio &affrad = AffineRadio());
91 
92  SmtkPoint Create(const Coordinate &left, const Coordinate &right);
93  SmtkPoint Clone(const SmtkPoint &point, const Coordinate &left);
94 
95  inline BigInt OffImageErrorCount() const { return (m_offImage); }
96  inline BigInt SpiceErrorCount() const { return (m_spiceErr); }
97 
99  PvlGroup RegTemplate() { return (m_gruen->RegTemplate()); }
101  Pvl RegistrationStatistics() { return (m_gruen->RegistrationStatistics()); }
102 
103  private:
104  SmtkMatcher &operator=(const SmtkMatcher &matcher); // Assignment disabled
105  SmtkMatcher(const SmtkMatcher &matcher); // Copy const disabled
106 
107  Cube *m_lhCube; // Left image cube (not owned)
108  Cube *m_rhCube; // Right image cube (not owned)
109  QSharedPointer<Gruen> m_gruen; // Gruen matcher
110  BigInt m_offImage; // Offimage counter
111  BigInt m_spiceErr; // SPICE distance error
112  bool m_useAutoReg; // Select AutoReg features
113  const gsl_rng_type * T; // GSL random number type
114  gsl_rng * r; // GSL random number generator
115 
116  void randomNumberSetup();
117  bool validate(const bool &throwError = true) const;
118 
119  inline Camera &lhCamera() { return (*m_lhCube->camera()); }
120  inline Camera &rhCamera() { return (*m_rhCube->camera()); }
121 
122  Coordinate getLineSample(Camera &camera, const Coordinate &geom);
123  Coordinate getLatLon(Camera &camera, const Coordinate &pnt);
124 
125  bool inCube(const Camera &camera, const Coordinate &point) const;
126 
127  SmtkPoint makeRegisteredPoint(const PointGeometry &left,
128  const PointGeometry &right, Gruen *gruen);
129 };
130 } // namespace Isis
131 
132 #endif
Isis::SmtkMatcher::FindSmallestEV
SmtkQStackIter FindSmallestEV(SmtkQStack &stack)
Find the smallest eigen value on the given stack.
Definition: SmtkMatcher.cpp:149
Isis::SmtkMatcher::setGruenDef
void setGruenDef(const QString &regdef)
Initialize Gruen algorithm with definitions in Pvl file provided.
Definition: SmtkMatcher.cpp:78
Isis::SmtkMatcher::makeRegisteredPoint
SmtkPoint makeRegisteredPoint(const PointGeometry &left, const PointGeometry &right, Gruen *gruen)
Create an SmtkPoint from Gruen match result.
Definition: SmtkMatcher.cpp:620
Isis::SmtkPoint
Container for SMTK match points.
Definition: SmtkPoint.h:54
Isis::SmtkMatcher::getLatLon
Coordinate getLatLon(Camera &camera, const Coordinate &pnt)
Compute latitude, longitude from line,sample.
Definition: SmtkMatcher.cpp:562
Isis::SmtkMatcher::PatternChip
Chip * PatternChip() const
Return pattern chip.
Definition: SmtkMatcher.h:60
Isis::AffineRadio
Container for affine and radiometric parameters.
Definition: GruenTypes.h:242
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::SmtkMatcher::randomNumberSetup
void randomNumberSetup()
Initialize the random number generator.
Definition: SmtkMatcher.cpp:496
QSharedPointer
Definition: JigsawWorkOrder.h:28
Isis::Camera
Definition: Camera.h:236
Isis::Coordinate
Define a generic Y/X container.
Definition: GruenTypes.h:53
Isis::SmtkMatcher::RegistrationStatistics
Pvl RegistrationStatistics()
Return Gruen registration statistics.
Definition: SmtkMatcher.h:101
Isis::SmtkMatcher::Clone
SmtkPoint Clone(const SmtkPoint &point, const Coordinate &left)
Clone a point set from a nearby (left image) point and Gruen affine.
Definition: SmtkMatcher.cpp:467
Isis::SmtkMatcher::FindExpDistEV
SmtkQStackIter FindExpDistEV(SmtkQStack &stack, const double &seedsample, const double &minEV, const double &maxEV)
Find the best eigen value using exponential distribution formula.
Definition: SmtkMatcher.cpp:182
Isis::SmtkMatcher::validate
bool validate(const bool &throwError=true) const
Validates the state of the Camera and Gruen algoritm.
Definition: SmtkMatcher.cpp:517
Isis::SmtkMatcher::setImages
void setImages(Cube *lhImage, Cube *rhImage)
Assign cubes for matching.
Definition: SmtkMatcher.cpp:60
Isis::SmtkMatcher::SmtkMatcher
SmtkMatcher()
Construct default matcher.
Definition: SmtkMatcher.cpp:25
QHash
This is free and unencumbered software released into the public domain.
Definition: ControlNet.h:32
Isis::SmtkMatcher::setWriteSubsearchChipPattern
void setWriteSubsearchChipPattern(const QString &fileptrn="SmtkMatcher")
Set file pattern for output subsearch chips.
Definition: SmtkMatcher.cpp:132
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::PointPair
Define a point set of left, right and geometry at that location.
Definition: GruenTypes.h:171
Isis::SmtkMatcher::RegTemplate
PvlGroup RegTemplate()
Return Gruen template parameters.
Definition: SmtkMatcher.h:99
Isis::BigInt
long long int BigInt
Big int.
Definition: Constants.h:49
Isis::SmtkMatcher::~SmtkMatcher
~SmtkMatcher()
Free random number generator in destructor.
Definition: SmtkMatcher.cpp:54
Isis::SmtkMatcher::getLineSample
Coordinate getLineSample(Camera &camera, const Coordinate &geom)
Compute line,sample from latitude, longitude.
Definition: SmtkMatcher.cpp:587
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::SmtkMatcher::isValid
bool isValid(const Coordinate &pnt)
Determine if a point is valid in both left/right images.
Definition: SmtkMatcher.cpp:101
Isis::SmtkMatcher::inCube
bool inCube(const Camera &camera, const Coordinate &point) const
Determines if the line/sample is within physical cube boundaries.
Definition: SmtkMatcher.cpp:540
Isis::Cube::camera
Camera * camera()
Return a camera associated with the cube.
Definition: Cube.cpp:1451
Isis::Chip
A small chip of data used for pattern matching.
Definition: Chip.h:86
Isis::PointGeometry
Container for a point and its geometry.
Definition: SmtkPoint.h:24
Isis::SmtkMatcher::Create
SmtkPoint Create(const Coordinate &left, const Coordinate &right)
Create a valid, unregistered SmtkPoint.
Definition: SmtkMatcher.cpp:427
Isis::SmtkMatcher
Workhorse of stereo matcher.
Definition: SmtkMatcher.h:45
Isis::SmtkMatcher::FitChip
Chip * FitChip() const
Returns the fit chip.
Definition: SmtkMatcher.h:72
Isis::SmtkMatcher::Register
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...
Definition: SmtkMatcher.cpp:250
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::SmtkMatcher::SearchChip
Chip * SearchChip() const
Return search chip.
Definition: SmtkMatcher.h:66