Isis 3 Programmer Reference
Equalization.h
Go to the documentation of this file.
1 #ifndef Equalization_h
2 #define Equalization_h
3 
26 #include <vector>
27 
28 #include <QString>
29 #include <QStringList>
30 
31 #include "FileList.h"
32 #include "LeastSquares.h"
33 #include "OverlapNormalization.h"
34 
35 using namespace std;
36 
37 namespace Isis {
38  class Buffer;
39  class OverlapStatistics;
40  class Pvl;
41  class PvlGroup;
42  class PvlObject;
43  class Statistics;
138  class Equalization {
139  public:
140  Equalization(OverlapNormalization::SolutionType sType, QString fromListName);
141  virtual ~Equalization();
142 
143  void addHolds(QString holdListName);
144 
145  void calculateStatistics(double samplingPercent,
146  int mincnt,
147  bool wtopt,
148  LeastSquares::SolveMethod methodType);
149  void recalculateStatistics(QString inStatsFileName);
150  void importStatistics(QString instatsFileName);
151  void applyCorrection(QString toListName);
152 
153  PvlGroup getResults();
154  void write(QString outstatsFileName);
155 
156  double evaluate(double dn, int imageIndex, int bandIndex) const;
157 
158  protected:
167  public:
168  ImageAdjustment(OverlapNormalization::SolutionType sType) { m_sType = sType; }
169  ~ImageAdjustment() {}
170 
171  void addGain(double gain) {
172  gains.push_back(gain);
173  }
174 
175  void addOffset(double offset) {
176  offsets.push_back(offset);
177  }
178 
179  void addAverage(double average) {
180  avgs.push_back(average);
181  }
182 
183  double getGain(int index) const {
184  return gains[index];
185  }
186 
187  double getOffset(int index) const {
188  return offsets[index];
189  }
190 
191  double getAverage(int index) const {
192  return avgs[index];
193  }
194 
195  double evaluate(double dn, int index) const {
196  double result = Null;
197 
198  double gain = gains[index];
199  if (m_sType != OverlapNormalization::GainsWithoutNormalization) {
200  double offset = offsets[index];
201  double avg = avgs[index];
202  result = (dn - avg) * gain + offset + avg;
203  }
204  else {
205  result = dn * gain;
206  }
207 
208  return result;
209  }
210 
211  private:
212  vector<double> gains;
213  vector<double> offsets;
214  vector<double> avgs;
215 
217  };
218 
227  public:
235  CalculateFunctor(Statistics *stats, double percent) {
236  m_stats = stats;
237  m_linc = (int) (100.0 / percent + 0.5);
238  }
239 
240  virtual ~CalculateFunctor() {}
241 
242  void operator()(Buffer &in) const;
243 
244  protected:
245  virtual void addStats(Buffer &in) const;
246 
247  private:
249  int m_linc;
250  };
251 
259  class ApplyFunctor {
260  public:
261  ApplyFunctor(const ImageAdjustment *adjustment) {
262  m_adjustment = adjustment;
263  }
264 
265  void operator()(Buffer &in, Buffer &out) const;
266 
267  private:
269  };
270 
271  protected:
272  Equalization();
273  void loadInputs(QString fromListName);
274  void setInput(int index, QString value);
275  const FileList &getInputs() const;
276 
277  // Should these be protected or private? (Recall children, i.e. HiEqual... can't
278  // access Equalization's private vars directly)
279  void calculateBandStatistics();
280  void calculateOverlapStatistics();
281 
282  virtual void fillOutList(FileList &outList, QString toListName);
283  virtual void errorCheck(QString fromListName);
284 
285  void generateOutputs(FileList &outList);
286  void loadOutputs(FileList &outList, QString toListName);
287  void loadHolds(OverlapNormalization *oNorm);
288 
289  void setResults();
290 
291  void clearAdjustments();
292  void addAdjustment(ImageAdjustment *adjustment);
293 
294  void clearNormalizations();
295  void clearOverlapStatistics();
296 
297  void addValid(int count);
298  void addInvalid(int count);
299 
300  void fromPvl(const PvlObject &inStats);
301  void setSolved(bool solved);
302  bool isSolved() const;
303 
304  private:
305  void init();
306  QVector<int> validateInputStatistics(QString instatsFileName);
307 
310  bool m_wtopt;
311 
312  FileList m_imageList; //<! List of input image filenames
313 
319  int m_mincnt;
320 
321  int m_maxCube;
322  int m_maxBand;
323 
325 
326  vector<ImageAdjustment *> m_adjustments; //<! Corrective factors for equalization
327  vector<int> m_holdIndices;
328  vector<bool> m_doesOverlapList;
329  vector<bool> m_alreadyCalculated;
330  vector<OverlapNormalization *> m_overlapNorms;
331  vector<OverlapStatistics *> m_overlapStats;
332 
337 
339  };
340 };
341 
342 #endif
Buffer for reading and writing cube data.
Definition: Buffer.h:69
LeastSquares::SolveMethod m_lsqMethod
Least squares method for solving normalization correcitve factors.
Definition: Equalization.h:336
vector< int > m_holdIndices
Indices of images being held.
Definition: Equalization.h:327
vector< bool > m_doesOverlapList
Which images have a valid overlap.
Definition: Equalization.h:328
QStringList m_badFiles
List of image names that don&#39;t overlap.
Definition: Equalization.h:324
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:110
This class is used as a functor calculate image statistics.
Definition: Equalization.h:226
int m_maxCube
Number of input images.
Definition: Equalization.h:321
Namespace for the standard library.
const ImageAdjustment * m_adjustment
ImageAdjustment to equalize image.
Definition: Equalization.h:268
Internalizes a list of files.
Definition: FileList.h:70
OverlapNormalization::SolutionType m_sType
The normalization solution type for solving normalizations (offsets, gains, or both) ...
Definition: Equalization.h:334
bool m_normsSolved
Indicates if corrective factors were solved.
Definition: Equalization.h:308
SolutionType
Enumeration for whether user/programmer wants to calculate new gains, offsets, or both when solving...
This class is used as a functor to apply adjustments (equalize) to an image.
Definition: Equalization.h:259
bool m_wtopt
Whether or not overlaps should be weighted.
Definition: Equalization.h:310
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
Pvl * m_results
Calculation results and normalization corrective factors (if solved)
Definition: Equalization.h:338
CalculateFunctor(Statistics *stats, double percent)
Constructs a CalculateFunctor.
Definition: Equalization.h:235
Calculate the bases and multipliers for normalizing overlapping "data sets" (e.g., cubes).
int m_mincnt
Minimum number of pixels for an overlap to be considered valid.
Definition: Equalization.h:319
Statistics * m_stats
Calculated statistics.
Definition: Equalization.h:248
This class can be used to calculate, read in, and/or apply equalization statistics for a list of file...
Definition: Equalization.h:138
vector< OverlapStatistics * > m_overlapStats
Calculated overlap statistics.
Definition: Equalization.h:331
int m_invalidCnt
Number of invalid overlaps.
Definition: Equalization.h:318
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
vector< OverlapNormalization * > m_overlapNorms
Normalization data for input images.
Definition: Equalization.h:330
int m_linc
Line increment value when calculating statistics.
Definition: Equalization.h:249
Container for cube-like labels.
Definition: Pvl.h:135
vector< bool > m_alreadyCalculated
Which images that have statistics already calculated.
Definition: Equalization.h:329
int m_validCnt
Number of valid overlaps.
Definition: Equalization.h:317
bool m_recalculating
Indicates if recalculating with loaded statistics.
Definition: Equalization.h:309
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
double m_samplingPercent
Percentage of the lines to consider when gathering cube and overlap statistics (process-by-line) ...
Definition: Equalization.h:314
int m_maxBand
Number of bands in each input image.
Definition: Equalization.h:322
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74