Isis 3 Programmer Reference
AutoReg.h
1 #ifndef AutoReg_h
2 #define AutoReg_h
3 
9 /* SPDX-License-Identifier: CC0-1.0 */
10 
11 #include <vector>
12 
13 #include "Chip.h"
14 #include "Statistics.h"
15 
16 class QString;
17 
18 namespace Isis {
19  class AutoRegItem;
20  class Buffer;
21  class Pvl;
22 
167  class AutoReg {
168  public:
169  AutoReg(Pvl &pvl);
170 
171  virtual ~AutoReg();
172 
190  };
191 
198  Sobel
199  };
200 
202  inline Chip *PatternChip() {
203  return &p_patternChip;
204  };
205 
207  inline Chip *SearchChip() {
208  return &p_searchChip;
209  };
210 
212  inline Chip *FitChip() {
213  return &p_fitChip;
214  };
215 
218  if (p_gradientFilterType == None) {
219  return &p_patternChip;
220  }
221  else {
222  return &p_gradientPatternChip;
223  }
224  };
225 
228  if (p_gradientFilterType == None) {
229  return &p_searchChip;
230  }
231  else {
232  return &p_gradientSearchChip;
233  }
234  };
235 
238  return &p_reducedPatternChip;
239  };
240 
243  return &p_reducedSearchChip;
244  };
245 
247  inline Chip *ReducedFitChip() {
248  return &p_reducedFitChip;
249  };
250 
251  void SetSubPixelAccuracy(bool on);
252  void SetPatternValidPercent(const double percent);
253  void SetSubsearchValidPercent(const double percent);
254  void SetTolerance(double tolerance);
255  void SetChipInterpolator(const QString &interpolator);
256  void SetSurfaceModelWindowSize(int size);
257  void SetSurfaceModelDistanceTolerance(double distance);
258  void SetReductionFactor(int reductionFactor);
259  void SetPatternZScoreMinimum(double minimum);
260  void SetGradientFilterType(const QString &gradientFilterType);
261 
262  QString GradientFilterString() const;
263 
271  return p_subpixelAccuracy;
272  }
273 
276  return p_reduceFactor;
277  }
278 
280  double PatternValidPercent() const {
281  return p_patternValidPercent;
282  };
283 
285  double SubsearchValidPercent() const {
287  };
288 
290  inline double Tolerance() const {
291  return p_tolerance;
292  };
293 
295  double WindowSize() const {
296  return p_windowSize;
297  };
298 
300  double DistanceTolerance() const {
301  return p_distanceTolerance;
302  };
303 
310  void Distance(double &sampDistance, double &lineDistance) {
311  sampDistance = p_sampMovement;
312  lineDistance = p_lineMovement;
313  }
314 
316 
318  inline bool Success() const {
320  }
321 
323  inline double GoodnessOfFit() const {
324  return p_goodnessOfFit;
325  };
326 
327  inline bool IsIdeal(double fit);
328 
330  inline double ChipSample() const {
331  return p_chipSample;
332  };
333 
335  inline double ChipLine() const {
336  return p_chipLine;
337  };
338 
340  inline double CubeSample() const {
341  return p_cubeSample;
342  };
343 
345  inline double CubeLine() const {
346  return p_cubeLine;
347  };
348 
350  double MinimumZScore() const {
351  return p_minimumPatternZScore;
352  };
353 
360  void ZScores(double &score1, double &score2) const {
361  score1 = p_zScoreMin;
362  score2 = p_zScoreMax;
363  }
364 
366 
370  virtual double MostLenientTolerance() {
371  return DBL_MIN;
372  }
373 
380  virtual QString AlgorithmName() const = 0;
381 
383 
385 
386  protected:
393  inline void SetChipSample(double sample) {
394  p_chipSample = sample;
395  };
396 
404  inline void SetChipLine(double line) {
405  p_chipLine = line;
406  };
407 
413  inline void SetGoodnessOfFit(double fit) {
414  p_bestFit = fit;
415  };
416 
417  virtual AutoReg::RegisterStatus Registration(Chip &sChip, Chip &pChip,
418  Chip &fChip, int startSamp, int startLine, int endSamp, int endLine,
419  int bestSamp, int bestLine);
420 
421  void Parse(Pvl &pvl);
422  virtual bool CompareFits(double fit1, double fit2);
423  bool SetSubpixelPosition(Chip &window);
424  Chip Reduce(Chip &chip, int reductionFactor);
425 
433  virtual double IdealFit() const = 0;
434 
447  virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch) = 0;
448 
450 
461  virtual Pvl AlgorithmStatistics(Pvl &pvl) {
462  return (pvl);
463  }
464 
465  private:
471  void Match(Chip &sChip,
472  Chip &pChip,
473  Chip &fChip,
474  int startSamp,
475  int endSamp,
476  int startLine,
477  int endLine);
478  bool ComputeChipZScore(Chip &chip);
479  void Init();
480  void ApplyGradientFilter(Chip &chip);
481  void SobelGradient(Buffer &in, double &v);
482 
491 
493 
494  //TODO: remove these after control points are refactored.
505 
506  double p_zScoreMin;
507  double p_zScoreMax;
508 
512 
513  double p_chipSample;
514  double p_chipLine;
515  double p_cubeSample;
516  double p_cubeLine;
518  double p_tolerance;
519 
522 
523  double p_bestFit;
526  double p_sampMovement;
527  double p_lineMovement;
531  };
532 };
533 
534 #endif
Isis::AutoReg::p_minimumPatternZScore
double p_minimumPatternZScore
Minimum pattern Z-Score.
Definition: AutoReg.h:509
Isis::AutoReg::Init
void Init()
Initialize AutoReg object private variables.
Definition: AutoReg.cpp:114
Isis::AutoReg::GoodnessOfFit
double GoodnessOfFit() const
Return the goodness of fit of the match algorithm.
Definition: AutoReg.h:323
Isis::AutoReg::SetChipSample
void SetChipSample(double sample)
Sets the search chip subpixel sample that matches the pattern tack sample.
Definition: AutoReg.h:393
Isis::AutoReg::p_windowSize
int p_windowSize
Surface model window size.
Definition: AutoReg.h:520
Isis::AutoReg::~AutoReg
virtual ~AutoReg()
Destroy AutoReg object.
Definition: AutoReg.cpp:153
Isis::AutoReg::ReductionFactor
int ReductionFactor()
Return the reduction factor.
Definition: AutoReg.h:275
Isis::AutoReg::p_goodnessOfFit
double p_goodnessOfFit
Goodness of fit of the match algorithm.
Definition: AutoReg.h:517
Isis::AutoReg::p_reducedPatternChip
Chip p_reducedPatternChip
Pattern Chip with reduction factor.
Definition: AutoReg.h:488
Isis::AutoReg::p_distanceTolerance
double p_distanceTolerance
Maximum distance the surface model solution may be from the best whole pixel fit in the fit chip.
Definition: AutoReg.h:521
Isis::AutoReg::MinimumZScore
double MinimumZScore() const
Return minimumPatternZScore.
Definition: AutoReg.h:350
Isis::AutoReg::p_surfaceModelSolutionInvalidCount
int p_surfaceModelSolutionInvalidCount
Registration statistics SurfaceModelSolutionInvalid keyword.
Definition: AutoReg.h:503
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::AutoReg::Sobel
@ Sobel
Sobel gradient filter.
Definition: AutoReg.h:198
Isis::AutoReg::p_zScoreMin
double p_zScoreMin
First Z-Score of pattern chip.
Definition: AutoReg.h:506
Isis::AutoReg::p_cubeSample
double p_cubeSample
Cube sample.
Definition: AutoReg.h:515
Isis::AutoReg::p_patternChip
Chip p_patternChip
Chip to be matched.
Definition: AutoReg.h:483
Isis::AutoReg::None
@ None
default, no gradient filter
Definition: AutoReg.h:197
Isis::AutoReg::SetSurfaceModelWindowSize
void SetSurfaceModelWindowSize(int size)
Set the surface model window size.
Definition: AutoReg.cpp:480
Isis::AutoReg::p_sampMovement
double p_sampMovement
The number of samples the point moved.
Definition: AutoReg.h:526
Isis::AutoReg::p_fitChipToleranceNotMetCount
int p_fitChipToleranceNotMetCount
Registration statistics FitChipToleranceNotMet keyword.
Definition: AutoReg.h:501
Isis::AutoReg::ZScores
void ZScores(double &score1, double &score2) const
Return the ZScores of the pattern chip.
Definition: AutoReg.h:360
Isis::AutoReg::SetSubpixelPosition
bool SetSubpixelPosition(Chip &window)
Set the search chip sample and line to subpixel values if possible.
Definition: AutoReg.cpp:1087
Isis::AutoReg::PatternZScoreNotMet
@ PatternZScoreNotMet
Pattern data max or min does not pass the z-score test.
Definition: AutoReg.h:188
Isis::AutoReg::AdaptiveAlgorithmFailed
@ AdaptiveAlgorithmFailed
Error occured in Adaptive algorithm.
Definition: AutoReg.h:189
Isis::AutoReg::p_subpixelSuccesses
int p_subpixelSuccesses
Registration statistics Success keyword.
Definition: AutoReg.h:497
Isis::AutoReg::Parse
void Parse(Pvl &pvl)
Initialize parameters in the AutoReg class using a PVL specification.
Definition: AutoReg.cpp:194
Isis::AutoReg::SetReductionFactor
void SetReductionFactor(int reductionFactor)
Set the reduction factor used to speed up the pattern matching algorithm.
Definition: AutoReg.cpp:521
Isis::AutoReg::SetGoodnessOfFit
void SetGoodnessOfFit(double fit)
Sets the goodness of fit for adaptive algorithms.
Definition: AutoReg.h:413
Isis::AutoReg::p_bestSamp
int p_bestSamp
Sample value of best fit.
Definition: AutoReg.h:524
Isis::AutoReg::SobelGradient
void SobelGradient(Buffer &in, double &v)
Compute a Sobel gradient based on an input buffer.
Definition: AutoReg.cpp:1000
Isis::AutoReg::RegistrationSearchChip
Chip * RegistrationSearchChip()
Return pointer to search chip used in registration.
Definition: AutoReg.h:227
Isis::AutoReg::p_gradientPatternChip
Chip p_gradientPatternChip
Chip to be matched with gradient applied.
Definition: AutoReg.h:487
Isis::AutoReg::p_subpixelAccuracy
bool p_subpixelAccuracy
Indicates whether sub-pixel accuracy is enabled. Default is true.
Definition: AutoReg.h:492
Isis::AutoReg::p_chipSample
double p_chipSample
Chip sample.
Definition: AutoReg.h:513
Isis::AutoReg::Register
AutoReg::RegisterStatus Register()
Walk the pattern chip through the search chip to find the best registration.
Definition: AutoReg.cpp:587
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::AutoReg::SetSubsearchValidPercent
void SetSubsearchValidPercent(const double percent)
Set the amount of data in the search chip's subchip that must be valid.
Definition: AutoReg.cpp:367
Isis::AutoReg::SearchChip
Chip * SearchChip()
Return pointer to search chip.
Definition: AutoReg.h:207
Isis::AutoReg::p_reducedFitChip
Chip p_reducedFitChip
Fit Chip with reduction factor.
Definition: AutoReg.h:490
Isis::AutoReg::p_lineMovement
double p_lineMovement
The number of lines the point moved.
Definition: AutoReg.h:527
Isis::AutoReg::AutoReg
AutoReg(Pvl &pvl)
Create AutoReg object.
Definition: AutoReg.cpp:66
Isis::AutoReg::p_bestLine
int p_bestLine
Line value of best fit.
Definition: AutoReg.h:525
Isis::AutoReg::p_reduceFactor
int p_reduceFactor
Reduction factor.
Definition: AutoReg.h:528
Isis::AutoReg::p_zScoreMax
double p_zScoreMax
Second Z-Score of pattern chip.
Definition: AutoReg.h:507
Isis::AutoReg::AlgorithmName
virtual QString AlgorithmName() const =0
Returns the name of the algorithm.
Isis::AutoReg::p_registrationStatus
Isis::AutoReg::RegisterStatus p_registrationStatus
Registration status to be returned by Register().
Definition: AutoReg.h:529
Isis::AutoReg::p_fitChip
Chip p_fitChip
Results from MatchAlgorithm() method.
Definition: AutoReg.h:485
Isis::AutoReg::ChipSample
double ChipSample() const
Return the search chip sample that best matched.
Definition: AutoReg.h:330
Isis::AutoReg::p_reducedSearchChip
Chip p_reducedSearchChip
Search Chip with reduction factor.
Definition: AutoReg.h:489
Isis::AutoReg
Auto Registration class.
Definition: AutoReg.h:167
Isis::AutoReg::MatchAlgorithm
virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch)=0
Given two identically sized chips return a double that indicates how well they match.
Isis::AutoReg::SetGradientFilterType
void SetGradientFilterType(const QString &gradientFilterType)
Set the gradient filter type to be applied to the search and pattern chips.
Definition: AutoReg.cpp:273
Isis::AutoReg::ReducedSearchChip
Chip * ReducedSearchChip()
Return pointer to reduced search chip.
Definition: AutoReg.h:242
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::AutoReg::UpdatedTemplate
PvlGroup UpdatedTemplate()
Returns a PvlGroup containing the PvlKeywords of the parameters this object was most recently run wit...
Definition: AutoReg.cpp:1289
Isis::AutoReg::RegTemplate
PvlGroup RegTemplate()
This function returns the keywords that this object was created from.
Definition: AutoReg.cpp:1216
Isis::AutoReg::p_cubeLine
double p_cubeLine
Cube line.
Definition: AutoReg.h:516
Isis::AutoReg::SetTolerance
void SetTolerance(double tolerance)
Set the tolerance for an acceptable goodness of fit.
Definition: AutoReg.cpp:416
Isis::AutoReg::SurfaceModelSolutionInvalid
@ SurfaceModelSolutionInvalid
Could not model surface for sub-pixel accuracy.
Definition: AutoReg.h:186
Isis::AutoReg::SubPixelAccuracy
bool SubPixelAccuracy()
Return whether this object will attempt to register to whole or sub-pixel accuracy.
Definition: AutoReg.h:270
Isis::AutoReg::SuccessSubPixel
@ SuccessSubPixel
Success registering to sub-pixel accuracy.
Definition: AutoReg.h:181
Isis::AutoReg::p_patternChipNotEnoughValidDataCount
int p_patternChipNotEnoughValidDataCount
Registration statistics PatternNotEnoughValidData keyword.
Definition: AutoReg.h:498
Isis::AutoReg::p_surfaceModelDistanceInvalidCount
int p_surfaceModelDistanceInvalidCount
Registration statistics SurfaceModelDistanceInvalid keyword.
Definition: AutoReg.h:504
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::AutoReg::IdealFit
virtual double IdealFit() const =0
Returns the ideal (perfect) fit that could be returned by the MatchAlgorithm.
Isis::AutoReg::PatternChipNotEnoughValidData
@ PatternChipNotEnoughValidData
Not enough valid data in pattern chip.
Definition: AutoReg.h:182
Isis::AutoReg::MostLenientTolerance
virtual double MostLenientTolerance()
Minimum tolerance specific to algorithm.
Definition: AutoReg.h:370
Isis::AutoReg::CubeSample
double CubeSample() const
Return the search chip cube sample that best matched.
Definition: AutoReg.h:340
Isis::AutoReg::p_gradientFilterType
AutoReg::GradientFilterType p_gradientFilterType
Type of gradient filter to use before matching.
Definition: AutoReg.h:530
Isis::AutoReg::WindowSize
double WindowSize() const
Return window size.
Definition: AutoReg.h:295
Isis::AutoReg::Reduce
Chip Reduce(Chip &chip, int reductionFactor)
This method reduces the given chip by the given reduction factor.
Definition: AutoReg.cpp:539
Isis::AutoReg::p_subsearchValidPercent
double p_subsearchValidPercent
Percentage of data in subsearch chip that must be valid.
Definition: AutoReg.h:511
Isis::AutoReg::IsIdeal
bool IsIdeal(double fit)
Returns true if the fit parameter is arbitrarily close to the ideal fit value.
Definition: AutoReg.cpp:1162
Isis::AutoReg::PatternChip
Chip * PatternChip()
Return pointer to pattern chip.
Definition: AutoReg.h:202
Isis::AutoReg::Registration
virtual AutoReg::RegisterStatus Registration(Chip &sChip, Chip &pChip, Chip &fChip, int startSamp, int startLine, int endSamp, int endLine, int bestSamp, int bestLine)
Performs matching between the pattern and search at both whole-pixel and subpixel levels.
Definition: AutoReg.cpp:811
Isis::AutoReg::CompareFits
virtual bool CompareFits(double fit1, double fit2)
This virtual method must return if the 1st fit is equal to or better than the second fit.
Definition: AutoReg.cpp:1152
Isis::AutoReg::SurfaceModelDistanceInvalid
@ SurfaceModelDistanceInvalid
Surface model moves registration more than one pixel.
Definition: AutoReg.h:187
Isis::AutoReg::p_patternZScoreNotMetCount
int p_patternZScoreNotMetCount
Registration statistics PatternZScoreNotMet keyword.
Definition: AutoReg.h:499
Isis::AutoReg::ReducedFitChip
Chip * ReducedFitChip()
Return pointer to reduced fit chip.
Definition: AutoReg.h:247
Isis::AutoReg::PatternValidPercent
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:280
Isis::AutoReg::RegisterStatus
RegisterStatus
Enumeration of the Register() method's return status.
Definition: AutoReg.h:179
Isis::AutoReg::Tolerance
double Tolerance() const
Return match algorithm tolerance.
Definition: AutoReg.h:290
Isis::AutoReg::p_surfaceModelNotEnoughValidDataCount
int p_surfaceModelNotEnoughValidDataCount
Registration statistics SurfaceModelNotEnoughValidData keyword.
Definition: AutoReg.h:502
Isis::AutoReg::p_template
PvlObject p_template
AutoRegistration object that created this projection.
Definition: AutoReg.h:449
Isis::AutoReg::RegistrationStatistics
Pvl RegistrationStatistics()
This returns the cumulative registration statistics.
Definition: AutoReg.cpp:1177
Isis::AutoReg::FitChipToleranceNotMet
@ FitChipToleranceNotMet
Goodness of fit tolerance not satisfied.
Definition: AutoReg.h:184
Isis::AutoReg::p_searchChip
Chip p_searchChip
Chip to be searched for best registration.
Definition: AutoReg.h:484
Isis::AutoReg::ChipLine
double ChipLine() const
Return the search chip line that best matched.
Definition: AutoReg.h:335
Isis::AutoReg::FitChip
Chip * FitChip()
Return pointer to fit chip.
Definition: AutoReg.h:212
Isis::AutoReg::SurfaceModelNotEnoughValidData
@ SurfaceModelNotEnoughValidData
Not enough points to fit a surface model for sub-pixel accuracy.
Definition: AutoReg.h:185
Isis::AutoReg::p_tolerance
double p_tolerance
Tolerance for acceptable goodness of fit in match algorithm.
Definition: AutoReg.h:518
Isis::AutoReg::p_fitChipNoDataCount
int p_fitChipNoDataCount
Registration statistics FitChipNoData keyword.
Definition: AutoReg.h:500
Isis::AutoReg::p_chipLine
double p_chipLine
Chip line.
Definition: AutoReg.h:514
Isis::AutoReg::p_gradientSearchChip
Chip p_gradientSearchChip
Chip to be searched for best registration with gradient applied.
Definition: AutoReg.h:486
Isis::AutoReg::ReducedPatternChip
Chip * ReducedPatternChip()
Return pointer to reduced pattern chip.
Definition: AutoReg.h:237
Isis::AutoReg::SetSubPixelAccuracy
void SetSubPixelAccuracy(bool on)
If the sub-pixel accuracy is enabled, the Register() method will attempt to match the pattern chip to...
Definition: AutoReg.cpp:312
Isis::AutoReg::FitChipNoData
@ FitChipNoData
Fit chip did not have any valid data.
Definition: AutoReg.h:183
Isis::Chip
A small chip of data used for pattern matching.
Definition: Chip.h:86
Isis::AutoReg::p_totalRegistrations
int p_totalRegistrations
Registration Statistics Total keyword.
Definition: AutoReg.h:495
Isis::AutoReg::CubeLine
double CubeLine() const
Return the search chip cube line that best matched.
Definition: AutoReg.h:345
Isis::AutoReg::Distance
void Distance(double &sampDistance, double &lineDistance)
Return the distance point moved.
Definition: AutoReg.h:310
Isis::AutoReg::AlgorithmStatistics
virtual Pvl AlgorithmStatistics(Pvl &pvl)
Provide (adaptive) algorithms a chance to report results.
Definition: AutoReg.h:461
Isis::AutoReg::SetChipLine
void SetChipLine(double line)
Sets the search chip subpixel line that matches the pattern tack line.
Definition: AutoReg.h:404
Isis::AutoReg::SubsearchValidPercent
double SubsearchValidPercent() const
Return subsearch chip valid percent.
Definition: AutoReg.h:285
Isis::AutoReg::ApplyGradientFilter
void ApplyGradientFilter(Chip &chip)
Run a gradient filter over the chip.
Definition: AutoReg.cpp:927
Isis::AutoReg::p_bestFit
double p_bestFit
Goodness of fit for adaptive algorithms.
Definition: AutoReg.h:523
Isis::AutoReg::p_patternValidPercent
double p_patternValidPercent
Percentage of data in pattern chip that must be valid.
Definition: AutoReg.h:510
Isis::AutoReg::SetPatternZScoreMinimum
void SetPatternZScoreMinimum(double minimum)
Set the minimum pattern zscore.
Definition: AutoReg.cpp:394
Isis::AutoReg::Success
bool Success() const
Return whether the match algorithm succeeded or not.
Definition: AutoReg.h:318
Isis::AutoReg::SetChipInterpolator
void SetChipInterpolator(const QString &interpolator)
Sets the Chip class interpolator type to be used to load pattern and search chips.
Definition: AutoReg.cpp:440
Isis::AutoReg::SetPatternValidPercent
void SetPatternValidPercent(const double percent)
Set the amount of data in the pattern chip that must be valid.
Definition: AutoReg.cpp:339
Isis::AutoReg::SuccessPixel
@ SuccessPixel
Success registering to whole pixel.
Definition: AutoReg.h:180
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::AutoReg::RegistrationPatternChip
Chip * RegistrationPatternChip()
Return pointer to pattern chip used in registration.
Definition: AutoReg.h:217
Isis::AutoReg::ComputeChipZScore
bool ComputeChipZScore(Chip &chip)
This method computes the given Chip's Z-Score.
Definition: AutoReg.cpp:895
Isis::AutoReg::p_pixelSuccesses
int p_pixelSuccesses
Registration statistics Success keyword.
Definition: AutoReg.h:496
Isis::AutoReg::Match
void Match(Chip &sChip, Chip &pChip, Chip &fChip, int startSamp, int endSamp, int startLine, int endLine)
Empty copy constructor.
Definition: AutoReg.cpp:1031
Isis::AutoReg::SetSurfaceModelDistanceTolerance
void SetSurfaceModelDistanceTolerance(double distance)
Set a distance the surface model solution is allowed to move away from the best whole pixel fit in th...
Definition: AutoReg.cpp:501
Isis::AutoReg::GradientFilterType
GradientFilterType
Enumeration of the different types of gradient filters that can be applied to the pattern and search ...
Definition: AutoReg.h:196
Isis::AutoReg::DistanceTolerance
double DistanceTolerance() const
Return distance tolerance.
Definition: AutoReg.h:300