40 const char *ProcessMosaic::TRACKING_TABLE_NAME =
"InputImages";
47 ProcessMosaic::ProcessMosaic() {
49 SetBandBinMatch(
true);
52 m_trackingEnabled =
false;
53 m_createOutputMosaic =
false;
54 m_bandPriorityBandNumber = 0;
55 m_bandPriorityKeyName =
"";
56 m_bandPriorityKeyValue =
"";
57 m_bandPriorityUseMaxValue =
false;
60 m_placeHighSatPixels =
false;
61 m_placeLowSatPixels =
false;
62 m_placeNullPixels =
false;
65 m_imageOverlay = PlaceImagesOnTop;
67 m_enforceMatchDEM =
false;
84 ProcessMosaic::~ProcessMosaic() {
114 void ProcessMosaic::StartProcess(
const int &os,
const int &ol,
const int &ob) {
116 if ((OutputCubes.size() != 1) || (InputCubes.size() != 1)) {
117 QString m =
"You must specify exactly one input and one output cube";
121 bool bTrackExists =
false;
122 if (!m_createOutputMosaic) {
123 bTrackExists = GetTrackStatus();
134 ins = (int)InputCubes[0]->sampleCount();
137 inl = (int)InputCubes[0]->lineCount();
140 inb = (int)InputCubes[0]->bandCount();
149 iss = iss - m_oss + 1;
150 ins = ins + m_oss - 1;
155 isl = isl - m_osl + 1;
156 inl = inl + m_osl - 1;
160 if ((m_oss + ins - 1) > OutputCubes[0]->sampleCount()) {
161 ins = OutputCubes[0]->sampleCount() - m_oss + 1;
164 if ((m_osl + inl - 1) > OutputCubes[0]->lineCount()) {
165 inl = OutputCubes[0]->lineCount() - m_osl + 1;
168 PvlGroup imgPosition(
"ImageLocation");
169 imgPosition +=
PvlKeyword(
"File", InputCubes[0]->fileName());
172 m_imagePositions += imgPosition;
175 if ((ins < 1) || (inl < 1)) {
176 QString m =
"The input cube does not overlap the mosaic";
182 isb = isb - m_osb + 1;
183 inb = inb + m_osb - 1;
187 p_progress->SetMaximumSteps(
188 (
int)InputCubes[0]->lineCount() * (
int)InputCubes[0]->bandCount());
189 p_progress->CheckStatus();
195 if (m_trackingEnabled) {
196 if (!(m_imageOverlay == UseBandPlacementCriteria ||
197 ((m_imageOverlay == PlaceImagesOnTop || m_imageOverlay == PlaceImagesBeneath) &&
199 (OutputCubes[0]->bandCount()-1) == 1) ||
200 (m_imageOverlay == PlaceImagesOnTop && m_placeHighSatPixels && m_placeLowSatPixels &&
201 m_placeNullPixels)) ){
202 QString m =
"Tracking cannot be True for multi-band Mosaic with ontop or beneath priority";
209 Pvl *inLab = InputCubes[0]->label();
211 if (m_enforceMatchDEM){
212 MatchDEMShapeModel();
216 if (m_enforceBandBinMatch) {
217 Pvl *outLab = OutputCubes[0]->label();
219 if (inLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
222 if (!m_createOutputMosaic && outLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
223 MatchBandBinGroup(isb, inb);
227 AddBandBinGroup(isb);
232 QString m =
"Match BandBin cannot be True when the Image does not have the BandBin group";
238 if (m_createOutputMosaic) {
239 if (inLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
240 AddBandBinGroup(isb);
243 AddDefaultBandBinGroup();
250 m_trackingEnabled =
true;
253 int iOriginBand = 0, iChanged = 0;
257 int bandPriorityInputBandNumber = -1;
258 int bandPriorityOutputBandNumber = -1;
259 if (m_imageOverlay == UseBandPlacementCriteria ) {
260 bandPriorityInputBandNumber = GetBandIndex(
true);
261 bandPriorityOutputBandNumber = GetBandIndex(
false);
265 int iIndex = GetIndexOffsetByPixelType();
268 if (m_trackingEnabled) {
269 SetMosaicOrigin(iIndex);
271 else if (m_imageOverlay == AverageImageWithMosaic && m_createOutputMosaic) {
275 m_onb = OutputCubes[0]->bandCount();
277 if (m_trackingEnabled) {
279 iOriginBand = OutputCubes[0]->bandCount();
283 if (m_imageOverlay == UseBandPlacementCriteria && !m_createOutputMosaic) {
284 BandComparison(iss, isl, isb, ins, inl, inb,
285 bandPriorityInputBandNumber, bandPriorityOutputBandNumber, iIndex);
288 else if (m_imageOverlay == AverageImageWithMosaic) {
291 QString msg =
"The mosaic cube needs a count band.";
298 if (m_imageOverlay == UseBandPlacementCriteria && !m_trackingEnabled ) {
299 BandPriorityWithNoTracking(iss, isl, isb, ins, inl, inb, bandPriorityInputBandNumber,
300 bandPriorityOutputBandNumber);
304 Portal iPortal(ins, 1, InputCubes[0]->pixelType());
305 Portal oPortal(ins, 1, OutputCubes[0]->pixelType());
306 Portal origPortal(ins, 1, OutputCubes[0]->pixelType());
308 for (
int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
309 for (
int il = isl, ol = m_osl; il < isl + inl; il++, ol++) {
312 InputCubes[0]->read(iPortal);
315 OutputCubes[0]->read(oPortal);
317 if (m_trackingEnabled) {
319 OutputCubes[0]->read(origPortal);
321 else if (m_imageOverlay == AverageImageWithMosaic) {
323 OutputCubes[0]->read(origPortal);
326 bool bChanged =
false;
328 for (
int pixel = 0; pixel < oPortal.
size(); pixel++) {
331 if (m_createOutputMosaic) {
332 oPortal[pixel] = iPortal[pixel];
333 if (m_trackingEnabled) {
334 origPortal[pixel] = iIndex;
337 else if (m_imageOverlay == AverageImageWithMosaic) {
346 else if (m_trackingEnabled && m_imageOverlay == UseBandPlacementCriteria) {
347 int iPixelOrigin = qRound(origPortal[pixel]);
349 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
350 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
351 iComparePortal.
SetPosition(iss, il, bandPriorityInputBandNumber);
352 InputCubes[0]->read(iComparePortal);
353 oComparePortal.
SetPosition(m_oss, ol, bandPriorityOutputBandNumber);
354 OutputCubes[0]->read(oComparePortal);
356 if (iPixelOrigin == iIndex) {
359 ( (!m_bandPriorityUseMaxValue &&
360 iComparePortal[pixel] < oComparePortal[pixel]) ||
361 (m_bandPriorityUseMaxValue &&
362 iComparePortal[pixel] > oComparePortal[pixel]) ) ) {
365 ( m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel]) ) ||
366 ( m_placeLowSatPixels &&
IsLowPixel (iPortal[pixel]) ) ||
367 ( m_placeNullPixels &&
IsNullPixel(iPortal[pixel]) ) ){
368 oPortal[pixel] = iPortal[pixel];
375 ( m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel]) ) ||
376 ( m_placeLowSatPixels &&
IsLowPixel (iPortal[pixel]) ) ||
377 ( m_placeNullPixels &&
IsNullPixel(iPortal[pixel]) ) ) {
378 oPortal[pixel] = iPortal[pixel];
386 else if (m_imageOverlay == PlaceImagesOnTop) {
389 (m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel])) ||
390 (m_placeLowSatPixels &&
IsLowPixel(iPortal[pixel])) ||
391 (m_placeNullPixels &&
IsNullPixel(iPortal[pixel]))) {
392 oPortal[pixel] = iPortal[pixel];
393 if (m_trackingEnabled) {
394 origPortal[pixel] = iIndex;
401 else if (m_imageOverlay == AverageImageWithMosaic) {
402 bChanged |= ProcessAveragePriority(pixel, iPortal, oPortal, origPortal);
405 else if (m_imageOverlay == PlaceImagesBeneath) {
407 oPortal[pixel] = iPortal[pixel];
410 if (m_trackingEnabled) {
411 origPortal[pixel] = iIndex;
419 if (m_trackingEnabled || m_imageOverlay == AverageImageWithMosaic) {
420 OutputCubes[0]->write(origPortal);
423 OutputCubes[0]->write(oPortal);
424 p_progress->CheckStatus();
437 return m_imagePositions;
478 Cube *ProcessMosaic::SetInputCube(
const QString ¶meter,
479 const int ss,
const int sl,
const int sb,
480 const int ns,
const int nl,
const int nb) {
483 if (InputCubes.size() > 0) {
484 QString m =
"You must specify exactly one input cube";
495 Cube *cInCube = Process::SetInputCube(parameter);
498 Pvl *cInPvl = InputCubes[0]->label();
499 if (cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).hasKeyword(
"Bands")) {
500 PvlKeyword &cBandKey = cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).findKeyword(
"Bands");
501 QString sStr(cBandKey[0]);
502 if (
toInt(sStr) < nb) {
503 QString m =
"The parameter number of input bands exceeds the actual number of bands in the "
548 Cube *ProcessMosaic::SetInputCube(
const QString &fname,
550 const int ss,
const int sl,
const int sb,
551 const int ns,
const int nl,
const int nb) {
554 if (InputCubes.size() > 0) {
555 QString m =
"You must specify exactly one input cube";
566 Cube *cInCube = Process::SetInputCube(fname, att);
569 Pvl *cInPvl = InputCubes[0]->label();
570 if (cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).hasKeyword(
"Bands")) {
571 PvlKeyword &cBandKey = cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).findKeyword(
"Bands");
572 QString sStr(cBandKey[0]);
573 if (
toInt(sStr) < nb) {
574 QString m =
"The parameter number of input bands exceeds the actual number of bands in the input cube";
596 Cube *ProcessMosaic::SetOutputCube(
const QString &psParameter) {
599 if (OutputCubes.size() > 0) {
600 QString m =
"You must specify exactly one output cube";
608 QString fname = Application::GetUserInterface().GetFileName(psParameter);
609 cube->
open(fname,
"rw");
616 if (m_createOutputMosaic) {
618 if (outLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
619 outLab->
findObject(
"IsisCube").deleteGroup(
"BandBin");
632 void ProcessMosaic::SetBandBinMatch(
bool enforceBandBinMatch) {
633 m_enforceBandBinMatch = enforceBandBinMatch;
657 void ProcessMosaic::SetMosaicOrigin(
int &index) {
659 QString sInputFile =
FileName(InputCubes[0]->fileName()).name();
660 QString sTableName = TRACKING_TABLE_NAME;
663 QString sSerialNumber = SerialNumber::Compose(*(InputCubes[0]));
664 int iFileNameLen = sInputFile.length();
665 int iSerialNumLen = sSerialNumber.length();
666 int iFieldLength = iSerialNumLen;
667 if (iFileNameLen > iSerialNumLen) {
668 iFieldLength = iFileNameLen;
672 QString sOutputFile =
FileName(OutputCubes[0]->fileName()).name();
674 Pvl *cPvlOut = OutputCubes[0]->label();
680 TableField cFileField(
"FileName", TableField::Text, iFieldLength);
681 cFileField = sInputFile;
682 cFileRecord += cFileField;
685 TableField cSNField(
"SerialNumber", TableField::Text, iFieldLength);
686 cSNField = sSerialNumber;
687 cFileRecord += cSNField;
689 int iNumObjs = cPvlOut->
objects();
694 for (
int i = 0; i < iNumObjs; i++) {
695 cPvlObj = cPvlOut->
object(i);
696 if (cPvlObj.
hasKeyword(
"Name", Pvl::Traverse)) {
698 if (cNameKey[0] == sTableName) {
702 m_trackingEnabled =
true;
705 Table cFileTable(sTableName);
709 OutputCubes[0]->read(cFileTable_Copy);
712 int iRecs = cFileTable_Copy.
Records();
716 switch (
sizeof(OutputCubes[0]->pixelType())) {
719 if (iRecs >= (VALID_MAX1 - 1))
724 if (iRecs > (VALID_MAX2 - VALID_MIN2 + 1))
730 if (iRecs > (FLOAT_STORE_INT_PRECISELY_MAX_VALUE -
731 FLOAT_STORE_INT_PRECISELY_MIN_VALUE + 1))
737 QString msg =
"The number of images in the Mosaic exceeds the pixel size";
741 for (
int i = 0; i < iRecs; i++) {
743 QString sTableFile = QString(QString(cFileTable_Copy[i][0]).toAscii().data());
744 int found = sTableFile.lastIndexOf(
".cub");
747 sTableFile.remove(found + 4);
750 if (sTableFile == sInputFile) {
758 if (
toInt(QString(cFieldKey[0])) < iFieldLength) {
760 TableField cFileFieldUpdate(
"FileName", TableField::Text, iFieldLength);
761 cFileFieldUpdate = (QString)cFileTable_Copy[i][0];
762 cFileRecordUpdate += cFileFieldUpdate;
765 TableField cSNFieldUpdate(
"SerialNumber", TableField::Text, iFieldLength);
766 cSNFieldUpdate = (QString)cFileTable_Copy[i][1];
767 cFileRecordUpdate += cSNFieldUpdate;
769 cFileTable =
Table(sTableName, cFileRecordUpdate);
772 cFileTable =
Table(sTableName, cFileTable_Copy[i]);
777 cFileTable += cFileTable_Copy[i];
783 cFileTable += cFileRecord;
786 OutputCubes[0]->write(cFileTable);
794 if (m_createOutputMosaic && m_trackingEnabled) {
795 Table cFileTable(sTableName, cFileRecord);
796 cFileTable += cFileRecord;
797 OutputCubes[0]->write(cFileTable);
807 void ProcessMosaic::SetBandKeyword(QString bandPriorityKeyName, QString bandPriorityKeyValue) {
808 m_bandPriorityKeyName = bandPriorityKeyName;
809 m_bandPriorityKeyValue = bandPriorityKeyValue;
816 void ProcessMosaic::SetBandNumber(
int bandPriorityBandNumber) {
817 m_bandPriorityBandNumber = bandPriorityBandNumber;
825 void ProcessMosaic::SetBandUseMaxValue(
bool useMax) {
826 m_bandPriorityUseMaxValue = useMax;
838 void ProcessMosaic::SetCreateFlag(
bool createOutputMosaic) {
839 m_createOutputMosaic = createOutputMosaic;
847 void ProcessMosaic::SetHighSaturationFlag(
bool placeHighSatPixels) {
848 m_placeHighSatPixels = placeHighSatPixels;
852 void ProcessMosaic::SetImageOverlay(ImageOverlay placement) {
853 m_imageOverlay = placement;
861 void ProcessMosaic::SetLowSaturationFlag(
bool placeLowSatPixels) {
862 m_placeLowSatPixels = placeLowSatPixels;
869 void ProcessMosaic::SetMatchDEM(
bool matchDEM) {
870 m_enforceMatchDEM = matchDEM;
878 void ProcessMosaic::SetNullFlag(
bool placeNullPixels) {
879 m_placeNullPixels = placeNullPixels;
883 void ProcessMosaic::SetTrackFlag(
bool trackingEnabled) {
884 m_trackingEnabled = trackingEnabled;
891 bool ProcessMosaic::GetHighSaturationFlag()
const {
892 return m_placeHighSatPixels;
900 return m_imageOverlay;
907 bool ProcessMosaic::GetLowSaturationFlag()
const {
908 return m_placeLowSatPixels;
915 bool ProcessMosaic::GetNullFlag()
const {
916 return m_placeNullPixels;
923 bool ProcessMosaic::GetTrackFlag()
const {
924 return m_trackingEnabled;
931 int ProcessMosaic::GetInputStartLineInMosaic()
const {
939 int ProcessMosaic::GetInputStartSampleInMosaic()
const {
947 int ProcessMosaic::GetInputStartBandInMosaic()
const {
959 switch (imageOverlay) {
960 case PlaceImagesOnTop:
964 case PlaceImagesBeneath:
968 case UseBandPlacementCriteria:
972 case AverageImageWithMosaic:
976 case NumImageOverlayOptions:
982 "Cannot convert overlay [" +
toString((
int)imageOverlay) +
"] to a string",
995 QString imageOverlayStringUpper = imageOverlayString.toUpper();
996 for (
int i = 0; i < NumImageOverlayOptions; i++) {
997 if (OverlayToString((
ImageOverlay)i).toUpper() == imageOverlayStringUpper)
1002 "The text [" + imageOverlayString +
"] does not correspond to any known "
1003 "image overlay modes (mosaic priorities)",
1015 void ProcessMosaic::MatchDEMShapeModel() {
1016 Pvl* inLabel = InputCubes[0]->label();
1017 Pvl* outLabel = OutputCubes[0]->label();
1019 if (outLabel->
findObject(
"IsisCube").hasGroup(
"Mosaic")) {
1022 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
1026 QString sShapeModel = inMosaicGrp.
findKeyword(
"ShapeModel")[0];
1027 int found = sShapeModel.lastIndexOf(
"/");
1029 sShapeModel.remove(0, found + 1);
1031 if (sShapeModel == outShapeModelKey[0]) {
1036 QString sErrMsg =
"Input and Mosaic DEM Shape Model do not match";
1041 if (m_createOutputMosaic) {
1042 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
1043 QString sShapeModel =
1044 inLabel->
findObject(
"IsisCube").findGroup(
"Kernels").findKeyword(
"ShapeModel")[0];
1045 int found = sShapeModel.lastIndexOf(
"/");
1047 sShapeModel.remove(0, found+1);
1052 shapeModelKey += sShapeModel;
1053 mosaicGrp += shapeModelKey;
1054 outIsisCubeObj += mosaicGrp;
1066 void ProcessMosaic::ResetCountBands()
1068 int iBand = OutputCubes[0]->bandCount();
1069 int iLines = OutputCubes[0]->lineCount();
1070 int iSample = OutputCubes[0]->sampleCount();
1072 Portal origPortal(iSample, 1, OutputCubes[0]->pixelType());
1073 int iStartCountBand = iBand/2 + 1;
1075 for (
int band=iStartCountBand; band<=iBand; band++) {
1076 for (
int i = 1; i <= iLines; i++) {
1078 OutputCubes[0]->read(origPortal);
1079 for (
int iPixel = 0; iPixel < origPortal.
size(); iPixel++) {
1080 origPortal[iPixel] = 0;
1082 OutputCubes[0]->write(origPortal);
1101 bool ProcessMosaic::ProcessAveragePriority(
int piPixel,
Portal& piPortal,
Portal& poPortal,
1104 bool bChanged=
false;
1106 int iCount = (int)porigPortal[piPixel];
1107 double dNewDN = (poPortal[piPixel] * iCount + piPortal[piPixel]) / (iCount + 1);
1108 poPortal[piPixel] = dNewDN;
1109 porigPortal[piPixel] =iCount +1;
1114 poPortal[piPixel] = piPortal[piPixel];
1115 porigPortal[piPixel] = 1;
1119 else if (
IsSpecial(piPortal[piPixel])) {
1120 if ((m_placeHighSatPixels &&
IsHighPixel(piPortal[piPixel])) ||
1121 (m_placeLowSatPixels &&
IsLowPixel (piPortal[piPixel])) ||
1122 (m_placeNullPixels &&
IsNullPixel(piPortal[piPixel]))) {
1123 poPortal[piPixel] = piPortal[piPixel];
1124 porigPortal[piPixel] = 0;
1143 void ProcessMosaic::MatchBandBinGroup(
int origIsb,
int &inb) {
1144 Pvl *inLab = InputCubes[0]->label();
1145 Pvl *outLab = OutputCubes[0]->label();
1150 QString msg =
"Pvl Group [BandBin] does not match between the input and output cubes";
1155 int isb = (origIsb - 1);
1156 int osb = (m_osb - 1);
1157 int iOutBandsHalf = OutputCubes[0]->bandCount()/2;
1159 for (
int i = 0; i < outBin.
keywords(); i++) {
1161 QString sOutName = outKey.
name();
1164 for (
int j = osb, k = isb; j < outKey.
size() && k < inKey.
size(); j++, k++) {
1165 if (outKey[j] ==
"NA") {
1166 outKey[j] = inKey[k];
1167 if (m_imageOverlay == AverageImageWithMosaic) {
1168 if (sOutName.contains(
"Filter") ||
1169 sOutName.contains(
"Name")) {
1170 outKey[j+iOutBandsHalf] = inKey[k] +
"_Count";
1173 outKey[j+iOutBandsHalf] =
"Avg_Count";
1177 else if (outKey[j] != inKey[k]) {
1178 QString msg =
"Pvl Group [BandBin] in Key[" + outKey.
name() +
"] In value" + inKey[k] +
1179 "and Out value=" + outKey[j] +
" do not match";
1185 QString msg =
"Pvl Group [BandBin] In Keyword[" + inBin[i].
name() +
"] and Out Keyword[" +
1186 outBin[i].
name() +
"] does not match";
1191 int inputRange = InputCubes[0]->bandCount() - isb;
1192 int outputRange = OutputCubes[0]->bandCount() - osb;
1193 inb = min(inputRange, outputRange);
1208 void ProcessMosaic::AddBandBinGroup(
int origIsb) {
1209 Pvl *inLab = InputCubes[0]->label();
1210 Pvl *outLab = OutputCubes[0]->label();
1212 int iOutBands = OutputCubes[0]->bandCount();
1214 if (m_trackingEnabled) {
1217 else if (m_imageOverlay == AverageImageWithMosaic) {
1221 int isb = origIsb - 1;
1222 int osb = m_osb - 1;
1227 int iInBands = InputCubes[0]->bandCount();
1229 for (
int i = 0; i < cInBin.
keywords(); i++) {
1231 int iInKeySize = cInKey.
size();
1234 for (
int b = 0; b < osb; b++) {
1237 for (
int b = osb; b < iOutBands; b++) {
1238 if (isb < iInKeySize) {
1239 cOutKey += cInKey[isb++];
1248 if (m_trackingEnabled && iInBands == iInKeySize) {
1249 cOutKey +=
"TRACKING";
1253 else if (m_imageOverlay == AverageImageWithMosaic) {
1254 int iTotalOutBands = OutputCubes[0]->bandCount();
1256 int iOutStartBand = iOutBands + osb;
1257 QString sKeyName = cInKey.
name();
1258 bool bFilterKey =
false;
1259 if (sKeyName.contains(
"Filter") ||
1260 sKeyName.contains(
"Original") ||
1261 sKeyName.contains(
"Name")) {
1264 for (
int ob=iOutBands; ob<iTotalOutBands; ob++) {
1265 if (isb < iInKeySize && ob >= iOutStartBand) {
1267 cOutKey += cInKey[isb++] +
"_Count";
1282 if (cOutKey.unit() != cInKey.
unit()) {
1289 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1302 void ProcessMosaic::AddDefaultBandBinGroup() {
1303 Pvl *outLab = OutputCubes[0]->label();
1307 int iOutBands = OutputCubes[0]->bandCount();
1308 int iOutBandsTotal = iOutBands;
1310 if (m_trackingEnabled) {
1313 else if (m_imageOverlay == AverageImageWithMosaic) {
1319 for (
int i=0; i<iOutBands; i++) {
1323 if (m_imageOverlay == AverageImageWithMosaic) {
1324 for (
int i=iOutBands; i<iOutBandsTotal; i++) {
1325 cOutKey +=
"NA_Count";
1329 if (m_trackingEnabled) {
1330 cOutKey +=
"TRACKING";
1335 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1342 int ProcessMosaic::GetBandIndex(
bool inputFile) {
1343 bool bFound =
false;
1349 cPvlLabel = *(InputCubes[0]->label());
1350 if (m_bandPriorityBandNumber <= InputCubes[0]->bandCount() &&
1351 m_bandPriorityBandNumber > 0) {
1352 iBandIndex = m_bandPriorityBandNumber;
1357 cPvlLabel = *(OutputCubes[0]->label());
1358 if (m_bandPriorityBandNumber <= OutputCubes[0]->bandCount() &&
1359 m_bandPriorityBandNumber > 0) {
1360 iBandIndex = m_bandPriorityBandNumber;
1388 if (!m_bandPriorityBandNumber) {
1390 if (cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).hasKeyword(m_bandPriorityKeyName)) {
1391 cKeyName = cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).findKeyword(m_bandPriorityKeyName);
1393 int iSize = cKeyName.
size();
1394 for (
int i = 0; i < iSize; i++) {
1395 if (m_bandPriorityKeyValue.toUpper() == cKeyName[i].toUpper()) {
1405 QString msg =
"Invalid Band / Key Name, Value ";
1426 void ProcessMosaic::BandComparison(
int iss,
int isl,
int isb,
int ins,
int inl,
int inb,
1427 int bandPriorityInputBandNumber,
int bandPriorityOutputBandNumber,
int index) {
1430 Portal cIportal(ins, 1, InputCubes[0]->pixelType());
1431 Portal cOportal(ins, 1, OutputCubes[0]->pixelType());
1432 Portal origPortal(ins, 1, OutputCubes[0]->pixelType());
1435 int iOriginBand = OutputCubes[0]->bandCount();
1437 for (
int iIL = isl, iOL = m_osl; iIL < isl + inl; iIL++, iOL++) {
1439 cIportal.
SetPosition(iss, iIL, bandPriorityInputBandNumber);
1440 InputCubes[0]->read(cIportal);
1442 cOportal.
SetPosition(m_oss, iOL, bandPriorityOutputBandNumber);
1443 OutputCubes[0]->read(cOportal);
1446 OutputCubes[0]->read(origPortal);
1449 for (
int iPixel = 0; iPixel < cOportal.
size(); iPixel++) {
1451 (m_placeHighSatPixels &&
IsHighPixel(cIportal[iPixel])) ||
1452 (m_placeLowSatPixels &&
IsLowPixel(cIportal[iPixel])) ||
1453 (m_placeNullPixels &&
IsNullPixel(cIportal[iPixel]))) {
1454 origPortal[iPixel] = index;
1459 (m_bandPriorityUseMaxValue ==
false && cIportal[iPixel] < cOportal[iPixel]) ||
1460 (m_bandPriorityUseMaxValue ==
true && cIportal[iPixel] > cOportal[iPixel])) {
1461 origPortal[iPixel] = index;
1466 OutputCubes[0]->write(origPortal);
1476 void ProcessMosaic::BandPriorityWithNoTracking(
int iss,
int isl,
int isb,
int ins,
int inl,
1477 int inb,
int bandPriorityInputBandNumber,
1478 int bandPriorityOutputBandNumber) {
1483 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
1484 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
1485 Portal resultsPortal ( ins, 1, OutputCubes[0]->pixelType() );
1488 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1489 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1491 for (
int inLine = isl, outLine = m_osl; inLine < isl + inl; inLine++, outLine++) {
1493 iComparePortal.
SetPosition(iss, inLine, bandPriorityInputBandNumber);
1494 InputCubes[0]->read(iComparePortal);
1496 oComparePortal.
SetPosition(m_oss, outLine, bandPriorityOutputBandNumber);
1497 OutputCubes[0]->read(oComparePortal);
1499 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1500 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1502 bool inCopy =
false;
1504 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1505 resultsPortal[iPixel] =
false;
1506 if (m_createOutputMosaic) {
1507 resultsPortal[iPixel] =
true;
1511 if ( (m_bandPriorityUseMaxValue ==
false &&
1512 iComparePortal[iPixel] < oComparePortal[iPixel]) ||
1513 (m_bandPriorityUseMaxValue ==
true &&
1514 iComparePortal[iPixel] > oComparePortal[iPixel]) ) {
1515 resultsPortal[iPixel] =
true;
1520 resultsPortal[iPixel] =
true;
1525 for (
int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
1528 InputCubes[0]->read(iPortal);
1531 OutputCubes[0]->read(oPortal);
1533 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1534 if (resultsPortal[iPixel]) {
1535 if (m_createOutputMosaic) {
1536 oPortal[iPixel] = iPortal[iPixel];
1539 (m_placeHighSatPixels &&
IsHighPixel(iPortal[iPixel]) ) ||
1540 (m_placeLowSatPixels &&
IsLowPixel (iPortal[iPixel]) ) ||
1541 (m_placeNullPixels &&
IsNullPixel(iPortal[iPixel]) ) ) {
1542 oPortal[iPixel] = iPortal[iPixel];
1546 oPortal[iPixel] = iPortal[iPixel];
1549 OutputCubes[0]->write(oPortal);
1567 int ProcessMosaic::GetIndexOffsetByPixelType() {
1570 switch (
SizeOf(OutputCubes[0]->pixelType())) {
1572 iOffset = VALID_MIN1;
1576 iOffset = VALID_MIN2;
1580 iOffset = FLOAT_STORE_INT_PRECISELY_MIN_VALUE;
1599 int ProcessMosaic::GetOriginDefaultByPixelType() {
1602 switch (
SizeOf(OutputCubes[0]->pixelType())) {
1616 QString msg =
"ProcessMosaic::GetOriginDefaultByPixelType - Invalid Pixel Type";
1632 void ProcessMosaic::ResetOriginBand() {
1633 int iBand = OutputCubes[0]->bandCount();
1634 int iLines = OutputCubes[0]->lineCount();
1635 int iSample = OutputCubes[0]->sampleCount();
1637 int iDefault = GetOriginDefaultByPixelType();
1639 Portal origPortal(iSample, 1, OutputCubes[0]->pixelType());
1641 for (
int i = 1; i <= iLines; i++) {
1643 OutputCubes[0]->read(origPortal);
1644 for (
int iPixel = 0; iPixel < origPortal.
size(); iPixel++) {
1645 origPortal[iPixel] = (float)(iDefault);
1647 OutputCubes[0]->write(origPortal);
1662 bool ProcessMosaic::GetTrackStatus() {
1664 Pvl *cPvlOut = OutputCubes[0]->label();
1666 bool bTableExists =
false;
1667 int iNumObjs = cPvlOut->
objects();
1672 for (
int i = 0; i < iNumObjs; i++) {
1673 cPvlObj = cPvlOut->
object(i);
1674 if (cPvlObj.
hasKeyword(
"Name", Pvl::Traverse)) {
1676 if (cNameKey[0] == TRACKING_TABLE_NAME) {
1677 bTableExists =
true;
1683 return bTableExists;