Isis 3 Developer Reference
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 
183  class AutoReg {
184  public:
185  AutoReg(Pvl &pvl);
186 
187  virtual ~AutoReg();
188 
206  };
207 
215  };
216 
218  inline Chip *PatternChip() {
219  return &p_patternChip;
220  };
221 
223  inline Chip *SearchChip() {
224  return &p_searchChip;
225  };
226 
228  inline Chip *FitChip() {
229  return &p_fitChip;
230  };
231 
234  if (p_gradientFilterType == None) {
235  return &p_patternChip;
236  }
237  else {
238  return &p_gradientPatternChip;
239  }
240  };
241 
244  if (p_gradientFilterType == None) {
245  return &p_searchChip;
246  }
247  else {
248  return &p_gradientSearchChip;
249  }
250  };
251 
254  return &p_reducedPatternChip;
255  };
256 
259  return &p_reducedSearchChip;
260  };
261 
263  inline Chip *ReducedFitChip() {
264  return &p_reducedFitChip;
265  };
266 
267  void SetSubPixelAccuracy(bool on);
268  void SetPatternValidPercent(const double percent);
269  void SetSubsearchValidPercent(const double percent);
270  void SetTolerance(double tolerance);
271  void SetChipInterpolator(const QString &interpolator);
272  void SetSurfaceModelWindowSize(int size);
273  void SetSurfaceModelDistanceTolerance(double distance);
274  void SetReductionFactor(int reductionFactor);
275  void SetPatternZScoreMinimum(double minimum);
276  void SetGradientFilterType(const QString &gradientFilterType);
277 
278  QString GradientFilterString() const;
279 
287  return p_subpixelAccuracy;
288  }
289 
292  return p_reduceFactor;
293  }
294 
296  double PatternValidPercent() const {
297  return p_patternValidPercent;
298  };
299 
301  double SubsearchValidPercent() const {
302  return p_subsearchValidPercent;
303  };
304 
306  inline double Tolerance() const {
307  return p_tolerance;
308  };
309 
311  double WindowSize() const {
312  return p_windowSize;
313  };
314 
316  double DistanceTolerance() const {
317  return p_distanceTolerance;
318  };
319 
326  void Distance(double &sampDistance, double &lineDistance) {
327  sampDistance = p_sampMovement;
328  lineDistance = p_lineMovement;
329  }
330 
332 
334  inline bool Success() const {
335  return (p_registrationStatus == SuccessPixel || p_registrationStatus == SuccessSubPixel);
336  }
337 
339  inline double GoodnessOfFit() const {
340  return p_goodnessOfFit;
341  };
342 
343  inline bool IsIdeal(double fit);
344 
346  inline double ChipSample() const {
347  return p_chipSample;
348  };
349 
351  inline double ChipLine() const {
352  return p_chipLine;
353  };
354 
356  inline double CubeSample() const {
357  return p_cubeSample;
358  };
359 
361  inline double CubeLine() const {
362  return p_cubeLine;
363  };
364 
366  double MinimumZScore() const {
367  return p_minimumPatternZScore;
368  };
369 
376  void ZScores(double &score1, double &score2) const {
377  score1 = p_zScoreMin;
378  score2 = p_zScoreMax;
379  }
380 
382 
386  virtual double MostLenientTolerance() {
387  return DBL_MIN;
388  }
389 
396  virtual QString AlgorithmName() const = 0;
397 
399 
401 
402  protected:
409  inline void SetChipSample(double sample) {
410  p_chipSample = sample;
411  };
412 
420  inline void SetChipLine(double line) {
421  p_chipLine = line;
422  };
423 
429  inline void SetGoodnessOfFit(double fit) {
430  p_bestFit = fit;
431  };
432 
433  virtual AutoReg::RegisterStatus Registration(Chip &sChip, Chip &pChip,
434  Chip &fChip, int startSamp, int startLine, int endSamp, int endLine,
435  int bestSamp, int bestLine);
436 
437  void Parse(Pvl &pvl);
438  virtual bool CompareFits(double fit1, double fit2);
439  bool SetSubpixelPosition(Chip &window);
440  Chip Reduce(Chip &chip, int reductionFactor);
441 
449  virtual double IdealFit() const = 0;
450 
463  virtual double MatchAlgorithm(Chip &pattern, Chip &subsearch) = 0;
464 
466 
477  virtual Pvl AlgorithmStatistics(Pvl &pvl) {
478  return (pvl);
479  }
480 
481  private:
487  void Match(Chip &sChip,
488  Chip &pChip,
489  Chip &fChip,
490  int startSamp,
491  int endSamp,
492  int startLine,
493  int endLine);
494  bool ComputeChipZScore(Chip &chip);
495  void Init();
496  void ApplyGradientFilter(Chip &chip);
497  void SobelGradient(Buffer &in, double &v);
498 
499  Chip p_patternChip;
500  Chip p_searchChip;
501  Chip p_fitChip;
502  Chip p_gradientSearchChip;
503  Chip p_gradientPatternChip;
504  Chip p_reducedPatternChip;
505  Chip p_reducedSearchChip;
506  Chip p_reducedFitChip;
507 
508  bool p_subpixelAccuracy;
509 
510  //TODO: remove these after control points are refactored.
511  int p_totalRegistrations;
512  int p_pixelSuccesses;
513  int p_subpixelSuccesses;
514  int p_patternChipNotEnoughValidDataCount;
515  int p_patternZScoreNotMetCount;
516  int p_fitChipNoDataCount;
517  int p_fitChipToleranceNotMetCount;
518  int p_surfaceModelNotEnoughValidDataCount;
519  int p_surfaceModelSolutionInvalidCount;
520  int p_surfaceModelDistanceInvalidCount;
521 
522  double p_zScoreMin;
523  double p_zScoreMax;
524 
525  double p_minimumPatternZScore;
526  double p_patternValidPercent;
527  double p_subsearchValidPercent;
528 
529  double p_chipSample;
530  double p_chipLine;
531  double p_cubeSample;
532  double p_cubeLine;
533  double p_goodnessOfFit;
534  double p_tolerance;
535 
536  int p_windowSize;
537  double p_distanceTolerance;
538 
539  double p_bestFit;
540  int p_bestSamp;
541  int p_bestLine;
542  double p_sampMovement;
543  double p_lineMovement;
544  int p_reduceFactor;
545  Isis::AutoReg::RegisterStatus p_registrationStatus;
546  AutoReg::GradientFilterType p_gradientFilterType;
547  };
548 };
549 
550 #endif
Buffer for reading and writing cube data.
Definition: Buffer.h:69
bool SetSubpixelPosition(Chip &window)
Set the search chip sample and line to subpixel values if possible.
Definition: AutoReg.cpp:1100
Error occured in Adaptive algorithm.
Definition: AutoReg.h:205
double MinimumZScore() const
Return minimumPatternZScore.
Definition: AutoReg.h:366
Success registering to sub-pixel accuracy.
Definition: AutoReg.h:197
virtual Pvl AlgorithmStatistics(Pvl &pvl)
Provide (adaptive) algorithms a chance to report results.
Definition: AutoReg.h:477
int ReductionFactor()
Return the reduction factor.
Definition: AutoReg.h:291
QString GradientFilterString() const
Definition: AutoReg.cpp:302
Success registering to whole pixel.
Definition: AutoReg.h:196
void SetChipSample(double sample)
Sets the search chip subpixel sample that matches the pattern tack sample.
Definition: AutoReg.h:409
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:102
PvlGroup RegTemplate()
This function returns the keywords that this object was created from.
Definition: AutoReg.cpp:1229
Chip * RegistrationSearchChip()
Return pointer to search chip used in registration.
Definition: AutoReg.h:243
Not enough valid data in pattern chip.
Definition: AutoReg.h:198
Not enough points to fit a surface model for sub-pixel accuracy.
Definition: AutoReg.h:201
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:233
Surface model moves registration more than one pixel.
Definition: AutoReg.h:203
void SetPatternZScoreMinimum(double minimum)
Set the minimum pattern zscore.
Definition: AutoReg.cpp:407
double DistanceTolerance() const
Return distance tolerance.
Definition: AutoReg.h:316
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:1175
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:213
Chip * SearchChip()
Return pointer to search chip.
Definition: AutoReg.h:223
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:824
double GoodnessOfFit() const
Return the goodness of fit of the match algorithm.
Definition: AutoReg.h:339
double CubeSample() const
Return the search chip cube sample that best matched.
Definition: AutoReg.h:356
void ZScores(double &score1, double &score2) const
Return the ZScores of the pattern chip.
Definition: AutoReg.h:376
void SetGradientFilterType(const QString &gradientFilterType)
Set the gradient filter type to be applied to the search and pattern chips.
Definition: AutoReg.cpp:286
AutoReg(Pvl &pvl)
Create AutoReg object.
Definition: AutoReg.cpp:79
double ChipLine() const
Return the search chip line that best matched.
Definition: AutoReg.h:351
void SetGoodnessOfFit(double fit)
Sets the goodness of fit for adaptive algorithms.
Definition: AutoReg.h:429
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
double Tolerance() const
Return match algorithm tolerance.
Definition: AutoReg.h:306
virtual double MostLenientTolerance()
Minimum tolerance specific to algorithm.
Definition: AutoReg.h:386
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
Chip * PatternChip()
Return pointer to pattern chip.
Definition: AutoReg.h:218
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:286
double CubeLine() const
Return the search chip cube line that best matched.
Definition: AutoReg.h:361
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:296
double ChipSample() const
Return the search chip sample that best matched.
Definition: AutoReg.h:346
void SetChipLine(double line)
Sets the search chip subpixel line that matches the pattern tack line.
Definition: AutoReg.h:420
bool Success() const
Return whether the match algorithm succeeded or not.
Definition: AutoReg.h:334
Fit chip did not have any valid data.
Definition: AutoReg.h:199
Chip * ReducedFitChip()
Return pointer to reduced fit chip.
Definition: AutoReg.h:263
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
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:258
Auto Registration class.
Definition: AutoReg.h:183
PvlGroup UpdatedTemplate()
Returns a PvlGroup containing the PvlKeywords of the parameters this object was most recently run wit...
Definition: AutoReg.cpp:1302
Sobel gradient filter.
Definition: AutoReg.h:214
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:200
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:1190
RegisterStatus
Enumeration of the Register() method&#39;s return status.
Definition: AutoReg.h:195
void Distance(double &sampDistance, double &lineDistance)
Return the distance point moved.
Definition: AutoReg.h:326
PvlObject p_template
AutoRegistration object that created this projection.
Definition: AutoReg.h:465
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
GradientFilterType
Enumeration of the different types of gradient filters that can be applied to the pattern and search ...
Definition: AutoReg.h:212
double SubsearchValidPercent() const
Return subsearch chip valid percent.
Definition: AutoReg.h:301
Chip * FitChip()
Return pointer to fit chip.
Definition: AutoReg.h:228
Could not model surface for sub-pixel accuracy.
Definition: AutoReg.h:202
Pattern data max or min does not pass the z-score test.
Definition: AutoReg.h:204
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
double WindowSize() const
Return window size.
Definition: AutoReg.h:311
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:253
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:1165
virtual ~AutoReg()
Destroy AutoReg object.
Definition: AutoReg.cpp:166