Isis Developer Reference
Equalization.h
Go to the documentation of this file.
1#ifndef Equalization_h
2#define Equalization_h
3
9/* SPDX-License-Identifier: CC0-1.0 */
10#include <vector>
11
12#include <QString>
13#include <QStringList>
14
15#include "FileList.h"
16#include "LeastSquares.h"
18
19using namespace std;
20
21namespace Isis {
22 class Buffer;
23 class OverlapStatistics;
24 class Pvl;
25 class PvlGroup;
26 class PvlObject;
27 class Statistics;
123 public:
124 Equalization(OverlapNormalization::SolutionType sType, QString fromListName);
125 virtual ~Equalization();
126
127 void addHolds(QString holdListName);
128
129 void calculateStatistics(double samplingPercent,
130 int mincnt,
131 bool wtopt,
132 LeastSquares::SolveMethod methodType);
133 void recalculateStatistics(QString inStatsFileName);
134 void importStatistics(QString instatsFileName);
135 void applyCorrection(QString toListName);
136
138 void write(QString outstatsFileName);
139
140 double evaluate(double dn, int imageIndex, int bandIndex) const;
141
142 protected:
151 public:
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 vector<double> gains;
197 vector<double> offsets;
198 vector<double> avgs;
199
201 };
202
211 public:
219 CalculateFunctor(Statistics *stats, double percent) {
220 m_stats = stats;
221 m_linc = (int) (100.0 / percent + 0.5);
222 }
223
224 virtual ~CalculateFunctor() {}
225
226 void operator()(Buffer &in) const;
227
228 protected:
229 virtual void addStats(Buffer &in) const;
230
231 private:
232 Statistics *m_stats;
233 int m_linc;
234 };
235
244 public:
245 ApplyFunctor(const ImageAdjustment *adjustment) {
246 m_adjustment = adjustment;
247 }
248
249 void operator()(Buffer &in, Buffer &out) const;
250
251 private:
252 const ImageAdjustment *m_adjustment;
253 };
254
255 protected:
256 Equalization();
257 void loadInputs(QString fromListName);
258 void setInput(int index, QString value);
259 const FileList &getInputs() const;
260
261 // Should these be protected or private? (Recall children, i.e. HiEqual... can't
262 // access Equalization's private vars directly)
265
266 virtual void fillOutList(FileList &outList, QString toListName);
267 virtual void errorCheck(QString fromListName);
268
269 void generateOutputs(FileList &outList);
270 void loadOutputs(FileList &outList, QString toListName);
271 void loadHolds(OverlapNormalization *oNorm);
272
273 void setResults();
274
275 void clearAdjustments();
276 void addAdjustment(ImageAdjustment *adjustment);
277
278 void clearNormalizations();
280
281 void addValid(int count);
282 void addInvalid(int count);
283
284 void fromPvl(const PvlObject &inStats);
285 void setSolved(bool solved);
286 bool isSolved() const;
287
288 private:
289 void init();
290 QVector<int> validateInputStatistics(QString instatsFileName);
291
292 bool m_normsSolved;
293 bool m_recalculating;
294 bool m_wtopt;
295
296 FileList m_imageList; //<! List of input image filenames
297
298 double m_samplingPercent;
301 int m_validCnt;
302 int m_invalidCnt;
303 int m_mincnt;
304
305 int m_maxCube;
306 int m_maxBand;
307
308 QStringList m_badFiles;
309
310 vector<ImageAdjustment *> m_adjustments; //<! Corrective factors for equalization
311 vector<int> m_holdIndices;
312 vector<bool> m_doesOverlapList;
313 vector<bool> m_alreadyCalculated;
314 vector<OverlapNormalization *> m_overlapNorms;
315 vector<OverlapStatistics *> m_overlapStats;
316
320 LeastSquares::SolveMethod m_lsqMethod;
321
322 Pvl *m_results;
323 };
324};
325
326#endif
Buffer for reading and writing cube data.
Definition Buffer.h:53
This class is used as a functor to apply adjustments (equalize) to an image.
Definition Equalization.h:243
ApplyFunctor(const ImageAdjustment *adjustment)
Definition Equalization.h:245
void operator()(Buffer &in, Buffer &out) const
Definition Equalization.cpp:1009
This class is used as a functor calculate image statistics.
Definition Equalization.h:210
void operator()(Buffer &in) const
Definition Equalization.cpp:995
virtual void addStats(Buffer &in) const
Definition Equalization.cpp:1003
CalculateFunctor(Statistics *stats, double percent)
Constructs a CalculateFunctor.
Definition Equalization.h:219
virtual ~CalculateFunctor()
Definition Equalization.h:224
Definition Equalization.h:150
ImageAdjustment(OverlapNormalization::SolutionType sType)
Definition Equalization.h:152
double getOffset(int index) const
Definition Equalization.h:171
double evaluate(double dn, int index) const
Definition Equalization.h:179
~ImageAdjustment()
Definition Equalization.h:153
double getGain(int index) const
Definition Equalization.h:167
void addAverage(double average)
Definition Equalization.h:163
double getAverage(int index) const
Definition Equalization.h:175
void addGain(double gain)
Definition Equalization.h:155
void addOffset(double offset)
Definition Equalization.h:159
This class can be used to calculate, read in, and/or apply equalization statistics for a list of file...
Definition Equalization.h:122
void calculateBandStatistics()
Calculates the image statistics on a band-by-band basis.
Definition Equalization.cpp:212
void importStatistics(QString instatsFileName)
Imports statistics for applying correction.
Definition Equalization.cpp:447
const FileList & getInputs() const
Definition Equalization.cpp:629
void generateOutputs(FileList &outList)
Generates the names of the equalized cubes if no output list is provided.
Definition Equalization.cpp:684
void clearAdjustments()
Frees image adjustments.
Definition Equalization.cpp:733
void loadOutputs(FileList &outList, QString toListName)
Checks that the output image list is correct.
Definition Equalization.cpp:702
virtual void errorCheck(QString fromListName)
Checks that the input images have the same mapping groups and same number of bands.
Definition Equalization.cpp:650
void setInput(int index, QString value)
Definition Equalization.cpp:624
void calculateStatistics(double samplingPercent, int mincnt, bool wtopt, LeastSquares::SolveMethod methodType)
Calculates the image and overlap statistics, and then determines corrective factors if possible.
Definition Equalization.cpp:136
void loadHolds(OverlapNormalization *oNorm)
Definition Equalization.cpp:724
PvlGroup getResults()
Returns general information about the equalization.
Definition Equalization.cpp:549
void addAdjustment(ImageAdjustment *adjustment)
Adds an image adjustment.
Definition Equalization.cpp:748
void fromPvl(const PvlObject &inStats)
Loads a previous Equalization state from an input pvl object.
Definition Equalization.cpp:803
void applyCorrection(QString toListName)
Equalizes the input images.
Definition Equalization.cpp:496
void setSolved(bool solved)
Sets solved state indicating if OverlapNormalizations (corrective factors) were solved.
Definition Equalization.cpp:899
void clearNormalizations()
Frees overlap normalizations.
Definition Equalization.cpp:756
void clearOverlapStatistics()
Frees overlap statistics.
Definition Equalization.cpp:767
double evaluate(double dn, int imageIndex, int bandIndex) const
Definition Equalization.cpp:588
void recalculateStatistics(QString inStatsFileName)
Recalculates statistics for any new input images.
Definition Equalization.cpp:428
void addInvalid(int count)
Increments the number of invalid overlaps by a given amount.
Definition Equalization.cpp:790
void write(QString outstatsFileName)
Write the equalization information (results) to a file.
Definition Equalization.cpp:582
virtual void fillOutList(FileList &outList, QString toListName)
Definition Equalization.cpp:634
void addHolds(QString holdListName)
Adds a list of images to be held in the equalization.
Definition Equalization.cpp:84
void loadInputs(QString fromListName)
Loads in the input images.
Definition Equalization.cpp:602
Equalization()
Default constructor.
Definition Equalization.cpp:40
void addValid(int count)
Increments the number of valid overlaps by a given amount.
Definition Equalization.cpp:780
bool isSolved() const
Indicates if the corrective factors were solved.
Definition Equalization.cpp:909
void calculateOverlapStatistics()
Calculates the overlap statistics for each pair of input images.
Definition Equalization.cpp:252
void setResults()
Creates the results pvl containing statistics and corrective factors.
Definition Equalization.cpp:324
virtual ~Equalization()
Destructor.
Definition Equalization.cpp:63
Internalizes a list of files.
Definition FileList.h:54
SolveMethod
Definition LeastSquares.h:112
Calculate the bases and multipliers for normalizing overlapping "data sets" (e.g.,...
Definition OverlapNormalization.h:61
SolutionType
Enumeration for whether user/programmer wants to calculate new gains, offsets, or both when solving.
Definition OverlapNormalization.h:111
@ GainsWithoutNormalization
The equation being solved for Gains, Offsets, and Both is output = (input - average) * gain + offset ...
Definition OverlapNormalization.h:135
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:93
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
const double Null
Value for an Isis Null pixel.
Definition SpecialPixel.h:95
Namespace for the standard library.