21 HiEqualization::HiEqualization(QString fromListName) :
23 loadInputs(fromListName);
27 HiEqualization::~HiEqualization() {
31 void HiEqualization::calculateStatistics() {
33 const FileList &imageList = getInputs();
34 QString maxCubeStr =
toString((
int) imageList.size());
37 vector<Statistics *> statsList;
38 vector<Statistics *> leftStatsList;
39 vector<Statistics *> rightStatsList;
40 for (
int img = 0; img < imageList.size(); img++) {
41 Statistics *stats =
new Statistics();
42 Statistics *statsLeft =
new Statistics();
43 Statistics *statsRight =
new Statistics();
45 QString cubeStr =
toString((
int) img + 1);
48 p.Progress()->SetText(
"Calculating Statistics for Cube " +
49 cubeStr +
" of " + maxCubeStr);
50 CubeAttributeInput att;
51 QString inp = imageList[img].toString();
52 p.SetInputCube(inp, att);
53 HiCalculateFunctor func(stats, statsLeft, statsRight, 100.0);
54 p.ProcessCubeInPlace(func,
false);
56 statsList.push_back(stats);
57 leftStatsList.push_back(statsLeft);
58 rightStatsList.push_back(statsRight);
62 OverlapNormalization oNorm(statsList);
66 for (
int i = 0; i < imageList.size() - 1; i++) {
68 oNorm.AddOverlap(*rightStatsList[i], i, *leftStatsList[j], j,
69 rightStatsList[i]->ValidPixels());
79 for (
int img = 0; img < imageList.size(); img++) {
81 adjustment->addGain(oNorm.Gain(img));
82 adjustment->addOffset(oNorm.Offset(img));
83 adjustment->addAverage(oNorm.Average(img));
92 void HiEqualization::fillOutList(FileList &outList, QString toListName) {
93 if (toListName.isEmpty()) {
100 for (
unsigned int i = 0; i < movedIndices.size(); i++) {
101 outList.push_back(tempList[movedIndices[i]]);
108 const FileList &imageList = getInputs();
111 if (imageList.size() > 10) {
112 QString msg =
"The input file [" + fromListName +
113 "] cannot contain more than 10 file names";
118 const int cpmm2ccd[] = {0, 1, 2, 3, 12, 4, 10, 11, 5, 13, 6, 7, 8, 9};
122 for (
int i = 0; i < imageList.size(); i++) {
127 int cpmmNumber = from1Instrument[
"CpmmNumber"];
128 ccds.push_back(cpmm2ccd[cpmmNumber]);
132 movedIndices.push_back(i);
135 QString msg =
"The [" + imageList[i].toString() +
136 "] file is not a valid HiRise image";
142 QString msg =
"The [" + imageList[i].toString() +
143 "] file is not a valid HiRise image";
149 for (
int i = 0; i < imageList.size() - 1; i++) {
150 int id1 = getCCDType(ccds[i]);
151 int id2 = getCCDType(ccds[i + 1]);
155 string msg =
"The list of input images must be all RED, all IR, or ";
162 for (
int i = 1; i < imageList.size(); i++) {
163 QString temp = imageList[i].toString();
165 int movedIndex = movedIndices[i];
170 while (j >= 0 && ccd2 > ccd1) {
171 setInput(j + 1, imageList[j].
toString());
172 ccds[j + 1] = ccds[j];
173 movedIndices[j + 1] = movedIndices[j];
176 if (j >= 0) ccd2 = ccds[j];
179 setInput(j + 1, temp);
181 movedIndices[j + 1] = movedIndex;
185 if (ccds[0] == 10 || ccds[0] == 11) {
186 if (imageList.size() != 2) {
187 string msg =
"A list of IR images must have exactly two ";
192 else if (ccds[0] == 12 || ccds[0] == 13) {
193 if (imageList.size() != 2) {
194 string msg =
"A list of BG images must have exactly two ";
203 int HiEqualization::getCCDType(
int ccd) {
205 return (ccd >= 0 && ccd <= 9) ? 0 : (ccd == 10 || ccd == 11) ? 1 : 2;
209 void HiEqualization::HiCalculateFunctor::addStats(Buffer &in)
const {
210 Equalization::CalculateFunctor::addStats(in);
217 unsigned int intersect = (in.size() == 682 || in.size() == 683) ?
218 18 : (48 * in.size()) / 2048;
220 m_statsLeft->
AddData(&in[0], intersect);
221 m_statsRight->
AddData(&in[in.size() - intersect], intersect);
void setSolved(bool solved)
Sets solved state indicating if OverlapNormalizations (corrective factors) were solved.
virtual void errorCheck(QString fromListName)
Checks that the input images have the same mapping groups and same number of bands.
void addValid(int count)
Increments the number of valid overlaps by a given amount.
void addAdjustment(ImageAdjustment *adjustment)
Adds an image adjustment.
Internalizes a list of files.
void clearAdjustments()
Frees image adjustments.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void loadOutputs(FileList &outList, QString toListName)
Checks that the output image list is correct.
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
void generateOutputs(FileList &outList)
Generates the names of the equalized cubes if no output list is provided.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
void setResults()
Creates the results pvl containing statistics and corrective factors.
Calculate both gains and offsets.
Namespace for ISIS/Bullet specific routines.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
IO Handler for Isis Cubes.