Isis 3.0
Back | Home
AutoReg.h
Go to the documentation of this file.
1 #ifndef AutoReg_h
2 #define AutoReg_h
3 
27 #include <vector>
28 
29 #include "Chip.h"
30 #include "Statistics.h"
31 
32 class QString;
33 
34 namespace Isis {
35  class AutoRegItem;
36  class Buffer;
37  class Pvl;
38 
177  class AutoReg {
178  public:
179  AutoReg(Pvl &pvl);
180 
181  virtual ~AutoReg();
182 
200  };
201 
209  };
210 
212  inline Chip *PatternChip() {
213  return &p_patternChip;
214  };
215 
217  inline Chip *SearchChip() {
218  return &p_searchChip;
219  };
220 
222  inline Chip *FitChip() {
223  return &p_fitChip;
224  };
225 
228  if (p_gradientFilterType == None) {
229  return &p_patternChip;
230  }
231  else {
232  return &p_gradientPatternChip;
233  }
234  };
235 
238  if (p_gradientFilterType == None) {
239  return &p_searchChip;
240  }
241  else {
242  return &p_gradientSearchChip;
243  }
244  };
245 
248  return &p_reducedPatternChip;
249  };
250 
253  return &p_reducedSearchChip;
254  };
255 
257  inline Chip *ReducedFitChip() {
258  return &p_reducedFitChip;
259  };
260 
261  void SetSubPixelAccuracy(bool on);
262  void SetPatternValidPercent(const double percent);
263  void SetSubsearchValidPercent(const double percent);
264  void SetTolerance(double tolerance);
265  void SetChipInterpolator(const QString &interpolator);
266  void SetSurfaceModelWindowSize(int size);
267  void SetSurfaceModelDistanceTolerance(double distance);
268  void SetReductionFactor(int reductionFactor);
269  void SetPatternZScoreMinimum(double minimum);
270  void SetGradientFilterType(const QString &gradientFilterType);
271 
272  QString GradientFilterString() const;
273 
281  return p_subpixelAccuracy;
282  }
283 
286  return p_reduceFactor;
287  }
288 
290  double PatternValidPercent() const {
291  return p_patternValidPercent;
292  };
293 
295  double SubsearchValidPercent() const {
296  return p_subsearchValidPercent;
297  };
298 
300  inline double Tolerance() const {
301  return p_tolerance;
302  };
303 
305  double WindowSize() const {
306  return p_windowSize;
307  };
308 
310  double DistanceTolerance() const {
311  return p_distanceTolerance;
312  };
313 
320  void Distance(double &sampDistance, double &lineDistance) {
321  sampDistance = p_sampMovement;
322  lineDistance = p_lineMovement;
323  }
324 
326 
328  inline bool Success() const {
329  return (p_registrationStatus == SuccessPixel || p_registrationStatus == SuccessSubPixel);
330  }
331 
333  inline double GoodnessOfFit() const {
334  return p_goodnessOfFit;
335  };
336 
337  inline bool IsIdeal(double fit);
338 
340  inline double ChipSample() const {
341  return p_chipSample;
342  };
343 
345  inline double ChipLine() const {
346  return p_chipLine;
347  };
348 
350  inline double CubeSample() const {
351  return p_cubeSample;
352  };
353 
355  inline double CubeLine() const {
356  return p_cubeLine;
357  };
358 
360  double MinimumZScore() const {
361  return p_minimumPatternZScore;
362  };
363 
370  void ZScores(double &score1, double &score2) const {
371  score1 = p_zScoreMin;
372  score2 = p_zScoreMax;
373  }
374 
376 
380  virtual double MostLenientTolerance() {
381  return DBL_MIN;
382  }
383 
390  virtual QString AlgorithmName() const = 0;
391 
393 
395 
396  protected:
403  inline void SetChipSample(double sample) {
404  p_chipSample = sample;
405  };
406 
414  inline void SetChipLine(double line) {
415  p_chipLine = line;
416  };
417 
423  inline void SetGoodnessOfFit(double fit) {
424  p_bestFit = fit;
425  };
426 
427  virtual AutoReg::RegisterStatus Registration(Chip &sChip, Chip &pChip,
428  Chip &fChip, int startSamp, int startLine, int endSamp, int endLine,
429  int bestSamp, int bestLine);
430 
431  void Parse(Pvl &pvl);
432  virtual bool CompareFits(double fit1, double fit2);
433  bool SetSubpixelPosition(Chip &window);
434  Chip Reduce(Chip &chip, int reductionFactor);
435 
443  virtual double IdealFit() const = 0;
444 
457  virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch) = 0;
458 
460 
471  virtual Pvl AlgorithmStatistics(Pvl &pvl) {
472  return (pvl);
473  }
474 
475  private:
481  void Match(Chip &sChip,
482  Chip &pChip,
483  Chip &fChip,
484  int startSamp,
485  int endSamp,
486  int startLine,
487  int endLine);
488  bool ComputeChipZScore(Chip &chip);
489  void Init();
490  void ApplyGradientFilter(Chip &chip);
491  void SobelGradient(Buffer &in, double &v);
492 
493  Chip p_patternChip;
494  Chip p_searchChip;
495  Chip p_fitChip;
496  Chip p_gradientSearchChip;
497  Chip p_gradientPatternChip;
498  Chip p_reducedPatternChip;
499  Chip p_reducedSearchChip;
500  Chip p_reducedFitChip;
501 
502  bool p_subpixelAccuracy;
503 
504  //TODO: remove these after control points are refactored.
505  int p_totalRegistrations;
506  int p_pixelSuccesses;
507  int p_subpixelSuccesses;
508  int p_patternChipNotEnoughValidDataCount;
509  int p_patternZScoreNotMetCount;
510  int p_fitChipNoDataCount;
511  int p_fitChipToleranceNotMetCount;
512  int p_surfaceModelNotEnoughValidDataCount;
513  int p_surfaceModelSolutionInvalidCount;
514  int p_surfaceModelDistanceInvalidCount;
515 
516  double p_zScoreMin;
517  double p_zScoreMax;
518 
519  double p_minimumPatternZScore;
520  double p_patternValidPercent;
521  double p_subsearchValidPercent;
522 
523  double p_chipSample;
524  double p_chipLine;
525  double p_cubeSample;
526  double p_cubeLine;
527  double p_goodnessOfFit;
528  double p_tolerance;
529 
530  int p_windowSize;
531  double p_distanceTolerance;
532 
533  double p_bestFit;
534  int p_bestSamp;
535  int p_bestLine;
536  double p_sampMovement;
537  double p_lineMovement;
538  int p_reduceFactor;
539  Isis::AutoReg::RegisterStatus p_registrationStatus;
540  AutoReg::GradientFilterType p_gradientFilterType;
541  };
542 };
543 
544 #endif
Buffer for reading and writing cube data.
Definition: Buffer.h:68
bool SetSubpixelPosition(Chip &window)
Set the search chip sample and line to subpixel values if possible.
Definition: AutoReg.cpp:1090
Error occured in Adaptive algorithm.
Definition: AutoReg.h:199
Success registering to sub-pixel accuracy.
Definition: AutoReg.h:191
virtual Pvl AlgorithmStatistics(Pvl &pvl)
Provide (adaptive) algorithms a chance to report results.
Definition: AutoReg.h:471
void ZScores(double &score1, double &score2) const
Return the ZScores of the pattern chip.
Definition: AutoReg.h:370
int ReductionFactor()
Return the reduction factor.
Definition: AutoReg.h:285
Success registering to whole pixel.
Definition: AutoReg.h:190
double DistanceTolerance() const
Return distance tolerance.
Definition: AutoReg.h:310
void SetChipSample(double sample)
Sets the search chip subpixel sample that matches the pattern tack sample.
Definition: AutoReg.h:403
double Tolerance() const
Return match algorithm tolerance.
Definition: AutoReg.h:300
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:514
A small chip of data used for pattern matching.
Definition: Chip.h:101
double WindowSize() const
Return window size.
Definition: AutoReg.h:305
QString GradientFilterString() const
Definition: AutoReg.cpp:302
PvlGroup RegTemplate()
This function returns the keywords that this object was created from.
Definition: AutoReg.cpp:1219
Chip * RegistrationSearchChip()
Return pointer to search chip used in registration.
Definition: AutoReg.h:237
Not enough valid data in pattern chip.
Definition: AutoReg.h:192
Not enough points to fit a surface model for sub-pixel accuracy.
Definition: AutoReg.h:195
void SetPatternValidPercent(const double percent)
Set the amount of data in the pattern chip that must be valid.
Definition: AutoReg.cpp:352
Chip * RegistrationPatternChip()
Return pointer to pattern chip used in registration.
Definition: AutoReg.h:227
Surface model moves registration more than one pixel.
Definition: AutoReg.h:197
void SetPatternZScoreMinimum(double minimum)
Set the minimum pattern zscore.
Definition: AutoReg.cpp:407
virtual QString AlgorithmName() const =0
Returns the name of the algorithm.
void Parse(Pvl &pvl)
Initialize parameters in the AutoReg class using a PVL specification.
Definition: AutoReg.cpp:207
bool IsIdeal(double fit)
Returns true if the fit parameter is arbitrarily close to the ideal fit value.
Definition: AutoReg.cpp:1165
void SetSurfaceModelWindowSize(int size)
Set the surface model window size.
Definition: AutoReg.cpp:493
AutoReg::RegisterStatus Register()
Walk the pattern chip through the search chip to find the best registration.
Definition: AutoReg.cpp:600
default, no gradient filter
Definition: AutoReg.h:207
Chip * SearchChip()
Return pointer to search chip.
Definition: AutoReg.h:217
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:822
void SetGradientFilterType(const QString &gradientFilterType)
Set the gradient filter type to be applied to the search and pattern chips.
Definition: AutoReg.cpp:286
double SubsearchValidPercent() const
Return subsearch chip valid percent.
Definition: AutoReg.h:295
AutoReg(Pvl &pvl)
Create AutoReg object.
Definition: AutoReg.cpp:79
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:290
void SetGoodnessOfFit(double fit)
Sets the goodness of fit for adaptive algorithms.
Definition: AutoReg.h:423
double CubeSample() const
Return the search chip cube sample that best matched.
Definition: AutoReg.h:350
double GoodnessOfFit() const
Return the goodness of fit of the match algorithm.
Definition: AutoReg.h:333
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:325
virtual double MostLenientTolerance()
Minimum tolerance specific to algorithm.
Definition: AutoReg.h:380
double ChipLine() const
Return the search chip line that best matched.
Definition: AutoReg.h:345
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
Chip * PatternChip()
Return pointer to pattern chip.
Definition: AutoReg.h:212
bool Success() const
Return whether the match algorithm succeeded or not.
Definition: AutoReg.h:328
virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch)=0
Given two identically sized chips return a double that indicates how well they match.
void SetReductionFactor(int reductionFactor)
Set the reduction factor used to speed up the pattern matching algorithm.
Definition: AutoReg.cpp:534
bool SubPixelAccuracy()
Return whether this object will attempt to register to whole or sub-pixel accuracy.
Definition: AutoReg.h:280
void SetChipLine(double line)
Sets the search chip subpixel line that matches the pattern tack line.
Definition: AutoReg.h:414
Fit chip did not have any valid data.
Definition: AutoReg.h:193
Chip * ReducedFitChip()
Return pointer to reduced fit chip.
Definition: AutoReg.h:257
void SetTolerance(double tolerance)
Set the tolerance for an acceptable goodness of fit.
Definition: AutoReg.cpp:429
Container for cube-like labels.
Definition: Pvl.h:135
double ChipSample() const
Return the search chip sample that best matched.
Definition: AutoReg.h:340
Chip Reduce(Chip &chip, int reductionFactor)
This method reduces the given chip by the given reduction factor.
Definition: AutoReg.cpp:552
Chip * ReducedSearchChip()
Return pointer to reduced search chip.
Definition: AutoReg.h:252
Auto Registration class.
Definition: AutoReg.h:177
PvlGroup UpdatedTemplate()
Returns a PvlGroup containing the PvlKeywords of the parameters this object was most recently run wit...
Definition: AutoReg.cpp:1292
Sobel gradient filter.
Definition: AutoReg.h:208
virtual double IdealFit() const =0
Returns the ideal (perfect) fit that could be returned by the MatchAlgorithm.
Goodness of fit tolerance not satisfied.
Definition: AutoReg.h:194
void SetChipInterpolator(const QString &interpolator)
Sets the Chip class interpolator type to be used to load pattern and search chips.
Definition: AutoReg.cpp:453
Pvl RegistrationStatistics()
This returns the cumulative registration statistics.
Definition: AutoReg.cpp:1180
RegisterStatus
Enumeration of the Register() method&#39;s return status.
Definition: AutoReg.h:189
void Distance(double &sampDistance, double &lineDistance)
Return the distance point moved.
Definition: AutoReg.h:320
PvlObject p_template
AutoRegistration object that created this projection.
Definition: AutoReg.h:459
GradientFilterType
Enumeration of the different types of gradient filters that can be applied to the pattern and search ...
Definition: AutoReg.h:206
Chip * FitChip()
Return pointer to fit chip.
Definition: AutoReg.h:222
Could not model surface for sub-pixel accuracy.
Definition: AutoReg.h:196
Pattern data max or min does not pass the z-score test.
Definition: AutoReg.h:198
double MinimumZScore() const
Return minimumPatternZScore.
Definition: AutoReg.h:360
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
double CubeLine() const
Return the search chip cube line that best matched.
Definition: AutoReg.h:355
void SetSubsearchValidPercent(const double percent)
Set the amount of data in the search chip&#39;s subchip that must be valid.
Definition: AutoReg.cpp:380
Chip * ReducedPatternChip()
Return pointer to reduced pattern chip.
Definition: AutoReg.h:247
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:1155
virtual ~AutoReg()
Destroy AutoReg object.
Definition: AutoReg.cpp:166

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:38