USGS

Isis 3.0 Object Programmers' Reference

Home

Equalization.h
Go to the documentation of this file.
1 #ifndef Equalization_h
2 #define Equalization_h
3 
26 #include <vector>
27 
28 // TODO Don't include
29 #include "FileList.h"
30 // The following includes are needed since class enumerations are used as input
31 // parameters (calculateStatistics)
32 #include "LeastSquares.h"
33 #include "OverlapNormalization.h"
34 
35 
36 namespace Isis {
37  class Buffer;
38  class Cube;
39  class FileList;
40  class OverlapStatistics;
41  class Pvl;
42  class PvlGroup;
43  class Statistics;
124  class Equalization {
125  public:
126  Equalization(OverlapNormalization::SolutionType sType, QString fromListName);
127  virtual ~Equalization();
128 
129  void addHolds(QString holdListName);
130 
131  void calculateStatistics(double sampPercent, int mincnt,
132  bool wtopt,
133  LeastSquares::SolveMethod methodType);
134  void importStatistics(QString instatsFileName);
135  void applyCorrection(QString toListName);
136 
137  PvlGroup getResults();
138  void write(QString outstatsFileName);
139 
140  double evaluate(double dn, int imageIndex, int bandIndex) const;
141 
142  protected:
151  public:
152  ImageAdjustment(OverlapNormalization::SolutionType sType) { m_sType = sType; }
153  ~ImageAdjustment() {}
154 
155  void addGain(double gain) {
156  gains.push_back(gain);
157  }
158 
159  void addOffset(double offset) {
160  offsets.push_back(offset);
161  }
162 
163  void addAverage(double average) {
164  avgs.push_back(average);
165  }
166 
167  double getGain(int index) const {
168  return gains[index];
169  }
170 
171  double getOffset(int index) const {
172  return offsets[index];
173  }
174 
175  double getAverage(int index) const {
176  return avgs[index];
177  }
178 
179  double evaluate(double dn, int index) const {
180  double result = Null;
181 
182  double gain = gains[index];
184  double offset = offsets[index];
185  double avg = avgs[index];
186  result = (dn - avg) * gain + offset + avg;
187  }
188  else {
189  result = dn * gain;
190  }
191 
192  return result;
193  }
194 
195  private:
196  std::vector<double> gains;
197  std::vector<double> offsets;
198  std::vector<double> avgs;
199 
201  };
202 
209  public:
210  CalculateFunctor(Statistics *stats, double percent) {
211  m_stats = stats;
212  m_linc = (int) (100.0 / percent + 0.5);
213  }
214 
215  virtual ~CalculateFunctor() {}
216 
217  void operator()(Buffer &in) const;
218 
219  protected:
220  virtual void addStats(Buffer &in) const;
221 
222  private:
223  Statistics *m_stats;
224  int m_linc;
225  };
226 
232  class ApplyFunctor {
233  public:
234  ApplyFunctor(const ImageAdjustment *adjustment) {
235  m_adjustment = adjustment;
236  }
237 
238  void operator()(Buffer &in, Buffer &out) const;
239 
240  private:
241  const ImageAdjustment *m_adjustment;
242  };
243 
244  protected:
245  Equalization();
246  void loadInputs(QString fromListName);
247  void setInput(int index, QString value);
248  const FileList & getInputs() const;
249 
250  virtual void fillOutList(FileList &outList, QString toListName);
251  virtual void errorCheck(QString fromListName);
252 
253  void generateOutputs(FileList &outList);
254  void loadOutputs(FileList &outList, QString toListName);
255  void loadHolds(OverlapNormalization *oNorm);
256 
257  void setResults(std::vector<OverlapStatistics> &overlapStats);
258  void setResults();
259 
260  void clearAdjustments();
261  void addAdjustment(ImageAdjustment *adjustment);
262 
263  void addValid(int count);
264  void addInvalid(int count);
265 
266  private:
267  void init();
268  std::vector<int> validateInputStatistics(QString instatsFileName);
269 
270  FileList m_imageList;
271  std::vector<ImageAdjustment *> m_adjustments;
272  std::vector<int> m_holdIndices;
273 
274  int m_validCnt;
275  int m_invalidCnt;
276 
277  int m_mincnt;
278  bool m_wtopt;
279 
280  int m_maxCube;
281  int m_maxBand;
282 
284 
285  Pvl *m_results;
286  };
287 };
288 
289 #endif