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 inputFileName =
FileName(InputCubes[0]->fileName()).name();
660 QString tableName = TRACKING_TABLE_NAME;
661 int inputFileNameLength = inputFileName.length();
664 QString inputFileSerialNumber = SerialNumber::Compose(*(InputCubes[0]));
665 int inputFileSerialNumberLength = inputFileSerialNumber.length();
668 int fieldLength = inputFileSerialNumberLength;
669 if (inputFileNameLength > inputFileSerialNumberLength) {
670 fieldLength = inputFileNameLength;
674 QString sOutputFile =
FileName(OutputCubes[0]->fileName()).name();
676 Pvl *cPvlOut = OutputCubes[0]->label();
682 TableField cFileField(
"FileName", TableField::Text, fieldLength);
683 cFileField = inputFileName;
684 cFileRecord += cFileField;
687 TableField cSNField(
"SerialNumber", TableField::Text, fieldLength);
688 cSNField = inputFileSerialNumber;
689 cFileRecord += cSNField;
691 int iNumObjs = cPvlOut->
objects();
696 for (
int i = 0; i < iNumObjs; i++) {
697 cPvlObj = cPvlOut->
object(i);
698 if (cPvlObj.
hasKeyword(
"Name", Pvl::Traverse)) {
700 if (cNameKey[0] == tableName) {
701 int existingTableFieldLength =
toInt(QString(cPvlObj.
findGroup(
"Field")
702 .findKeyword(
"Size")));
705 m_trackingEnabled =
true;
708 Table cFileTable(tableName);
712 OutputCubes[0]->read(cFileTable_Copy);
714 int existingTableRecords = cFileTable_Copy.
Records();
718 switch (
sizeof(OutputCubes[0]->pixelType())) {
721 if (existingTableRecords >= (VALID_MAX1 - 1)) bFull =
true;
725 if (existingTableRecords > (VALID_MAX2 - VALID_MIN2 + 1)) bFull =
true;
730 if (existingTableRecords > (FLOAT_STORE_INT_PRECISELY_MAX_VALUE -
731 FLOAT_STORE_INT_PRECISELY_MIN_VALUE + 1)) bFull =
true;
736 QString msg =
"The number of images in the Mosaic exceeds the pixel size";
740 for (
int i = 0;i < existingTableRecords;i++) {
742 QString sTableFile = QString(QString(cFileTable_Copy[i][0]).toLatin1().data());
743 int found = sTableFile.lastIndexOf(
".cub");
746 sTableFile.remove(found + 4);
749 if (sTableFile == inputFileName) {
758 if (existingTableFieldLength < fieldLength) {
762 TableField cFileFieldUpdate(
"FileName", TableField::Text, fieldLength);
763 cFileFieldUpdate = (QString)cFileTable_Copy[i][0];
764 record += cFileFieldUpdate;
767 TableField cSNFieldUpdate(
"SerialNumber", TableField::Text, fieldLength);
768 cSNFieldUpdate = (QString)cFileTable_Copy[i][1];
769 record += cSNFieldUpdate;
773 record = cFileTable_Copy[i];
779 cFileTable =
Table(tableName, record);
780 cFileTable += record;
784 cFileTable += record;
788 index += existingTableRecords;
794 TableField cFileFieldUpdate(
"FileName", TableField::Text, existingTableFieldLength);
795 cFileFieldUpdate = (QString)cFileRecord[0];
796 updateNewRecord += cFileFieldUpdate;
799 TableField cSNFieldUpdate(
"SerialNumber", TableField::Text, existingTableFieldLength);
800 cSNFieldUpdate = (QString)cFileRecord[1];
801 updateNewRecord += cSNFieldUpdate;
802 cFileTable += updateNewRecord;
806 cFileTable += cFileRecord;
810 OutputCubes[0]->write(cFileTable);
818 if (m_createOutputMosaic && m_trackingEnabled) {
819 Table cFileTable(tableName, cFileRecord);
820 cFileTable += cFileRecord;
821 OutputCubes[0]->write(cFileTable);
831 void ProcessMosaic::SetBandKeyword(QString bandPriorityKeyName, QString bandPriorityKeyValue) {
832 m_bandPriorityKeyName = bandPriorityKeyName;
833 m_bandPriorityKeyValue = bandPriorityKeyValue;
840 void ProcessMosaic::SetBandNumber(
int bandPriorityBandNumber) {
841 m_bandPriorityBandNumber = bandPriorityBandNumber;
849 void ProcessMosaic::SetBandUseMaxValue(
bool useMax) {
850 m_bandPriorityUseMaxValue = useMax;
862 void ProcessMosaic::SetCreateFlag(
bool createOutputMosaic) {
863 m_createOutputMosaic = createOutputMosaic;
871 void ProcessMosaic::SetHighSaturationFlag(
bool placeHighSatPixels) {
872 m_placeHighSatPixels = placeHighSatPixels;
876 void ProcessMosaic::SetImageOverlay(ImageOverlay placement) {
877 m_imageOverlay = placement;
885 void ProcessMosaic::SetLowSaturationFlag(
bool placeLowSatPixels) {
886 m_placeLowSatPixels = placeLowSatPixels;
893 void ProcessMosaic::SetMatchDEM(
bool matchDEM) {
894 m_enforceMatchDEM = matchDEM;
902 void ProcessMosaic::SetNullFlag(
bool placeNullPixels) {
903 m_placeNullPixels = placeNullPixels;
907 void ProcessMosaic::SetTrackFlag(
bool trackingEnabled) {
908 m_trackingEnabled = trackingEnabled;
915 bool ProcessMosaic::GetHighSaturationFlag()
const {
916 return m_placeHighSatPixels;
924 return m_imageOverlay;
931 bool ProcessMosaic::GetLowSaturationFlag()
const {
932 return m_placeLowSatPixels;
939 bool ProcessMosaic::GetNullFlag()
const {
940 return m_placeNullPixels;
947 bool ProcessMosaic::GetTrackFlag()
const {
948 return m_trackingEnabled;
955 int ProcessMosaic::GetInputStartLineInMosaic()
const {
963 int ProcessMosaic::GetInputStartSampleInMosaic()
const {
971 int ProcessMosaic::GetInputStartBandInMosaic()
const {
983 switch (imageOverlay) {
984 case PlaceImagesOnTop:
988 case PlaceImagesBeneath:
992 case UseBandPlacementCriteria:
996 case AverageImageWithMosaic:
1000 case NumImageOverlayOptions:
1006 "Cannot convert overlay [" +
toString((
int)imageOverlay) +
"] to a string",
1019 QString imageOverlayStringUpper = imageOverlayString.toUpper();
1020 for (
int i = 0; i < NumImageOverlayOptions; i++) {
1021 if (OverlayToString((
ImageOverlay)i).toUpper() == imageOverlayStringUpper)
1026 "The text [" + imageOverlayString +
"] does not correspond to any known "
1027 "image overlay modes (mosaic priorities)",
1039 void ProcessMosaic::MatchDEMShapeModel() {
1040 Pvl* inLabel = InputCubes[0]->label();
1041 Pvl* outLabel = OutputCubes[0]->label();
1043 if (outLabel->
findObject(
"IsisCube").hasGroup(
"Mosaic")) {
1046 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
1050 QString sShapeModel = inMosaicGrp.
findKeyword(
"ShapeModel")[0];
1051 int found = sShapeModel.lastIndexOf(
"/");
1053 sShapeModel.remove(0, found + 1);
1055 if (sShapeModel == outShapeModelKey[0]) {
1060 QString sErrMsg =
"Input and Mosaic DEM Shape Model do not match";
1065 if (m_createOutputMosaic) {
1066 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
1067 QString sShapeModel =
1068 inLabel->
findObject(
"IsisCube").findGroup(
"Kernels").findKeyword(
"ShapeModel")[0];
1069 int found = sShapeModel.lastIndexOf(
"/");
1071 sShapeModel.remove(0, found+1);
1076 shapeModelKey += sShapeModel;
1077 mosaicGrp += shapeModelKey;
1078 outIsisCubeObj += mosaicGrp;
1090 void ProcessMosaic::ResetCountBands()
1092 int iBand = OutputCubes[0]->bandCount();
1093 int iLines = OutputCubes[0]->lineCount();
1094 int iSample = OutputCubes[0]->sampleCount();
1096 Portal origPortal(iSample, 1, OutputCubes[0]->pixelType());
1097 int iStartCountBand = iBand/2 + 1;
1099 for (
int band=iStartCountBand; band<=iBand; band++) {
1100 for (
int i = 1; i <= iLines; i++) {
1102 OutputCubes[0]->read(origPortal);
1103 for (
int iPixel = 0; iPixel < origPortal.
size(); iPixel++) {
1104 origPortal[iPixel] = 0;
1106 OutputCubes[0]->write(origPortal);
1125 bool ProcessMosaic::ProcessAveragePriority(
int piPixel,
Portal& piPortal,
Portal& poPortal,
1128 bool bChanged=
false;
1130 int iCount = (int)porigPortal[piPixel];
1131 double dNewDN = (poPortal[piPixel] * iCount + piPortal[piPixel]) / (iCount + 1);
1132 poPortal[piPixel] = dNewDN;
1133 porigPortal[piPixel] =iCount +1;
1138 poPortal[piPixel] = piPortal[piPixel];
1139 porigPortal[piPixel] = 1;
1143 else if (
IsSpecial(piPortal[piPixel])) {
1144 if ((m_placeHighSatPixels &&
IsHighPixel(piPortal[piPixel])) ||
1145 (m_placeLowSatPixels &&
IsLowPixel (piPortal[piPixel])) ||
1146 (m_placeNullPixels &&
IsNullPixel(piPortal[piPixel]))) {
1147 poPortal[piPixel] = piPortal[piPixel];
1148 porigPortal[piPixel] = 0;
1167 void ProcessMosaic::MatchBandBinGroup(
int origIsb,
int &inb) {
1168 Pvl *inLab = InputCubes[0]->label();
1169 Pvl *outLab = OutputCubes[0]->label();
1174 QString msg =
"Pvl Group [BandBin] does not match between the input and output cubes";
1179 int isb = (origIsb - 1);
1180 int osb = (m_osb - 1);
1181 int iOutBandsHalf = OutputCubes[0]->bandCount()/2;
1183 for (
int i = 0; i < outBin.
keywords(); i++) {
1185 QString sOutName = outKey.
name();
1188 for (
int j = osb, k = isb; j < outKey.
size() && k < inKey.
size(); j++, k++) {
1189 if (outKey[j] ==
"NA") {
1190 outKey[j] = inKey[k];
1191 if (m_imageOverlay == AverageImageWithMosaic) {
1192 if (sOutName.contains(
"Filter") ||
1193 sOutName.contains(
"Name")) {
1194 outKey[j+iOutBandsHalf] = inKey[k] +
"_Count";
1197 outKey[j+iOutBandsHalf] =
"Avg_Count";
1201 else if (outKey[j] != inKey[k]) {
1202 QString msg =
"Pvl Group [BandBin] in Key[" + outKey.
name() +
"] In value" + inKey[k] +
1203 "and Out value=" + outKey[j] +
" do not match";
1209 QString msg =
"Pvl Group [BandBin] In Keyword[" + inBin[i].
name() +
"] and Out Keyword[" +
1210 outBin[i].
name() +
"] does not match";
1215 int inputRange = InputCubes[0]->bandCount() - isb;
1216 int outputRange = OutputCubes[0]->bandCount() - osb;
1217 inb = min(inputRange, outputRange);
1232 void ProcessMosaic::AddBandBinGroup(
int origIsb) {
1233 Pvl *inLab = InputCubes[0]->label();
1234 Pvl *outLab = OutputCubes[0]->label();
1236 int iOutBands = OutputCubes[0]->bandCount();
1238 if (m_trackingEnabled) {
1241 else if (m_imageOverlay == AverageImageWithMosaic) {
1245 int isb = origIsb - 1;
1246 int osb = m_osb - 1;
1251 int iInBands = InputCubes[0]->bandCount();
1253 for (
int i = 0; i < cInBin.
keywords(); i++) {
1255 int iInKeySize = cInKey.
size();
1258 for (
int b = 0; b < osb; b++) {
1261 for (
int b = osb; b < iOutBands; b++) {
1262 if (isb < iInKeySize) {
1263 cOutKey += cInKey[isb++];
1272 if (m_trackingEnabled && iInBands == iInKeySize) {
1273 cOutKey +=
"TRACKING";
1277 else if (m_imageOverlay == AverageImageWithMosaic) {
1278 int iTotalOutBands = OutputCubes[0]->bandCount();
1280 int iOutStartBand = iOutBands + osb;
1281 QString sKeyName = cInKey.
name();
1282 bool bFilterKey =
false;
1283 if (sKeyName.contains(
"Filter") ||
1284 sKeyName.contains(
"Original") ||
1285 sKeyName.contains(
"Name")) {
1288 for (
int ob=iOutBands; ob<iTotalOutBands; ob++) {
1289 if (isb < iInKeySize && ob >= iOutStartBand) {
1291 cOutKey += cInKey[isb++] +
"_Count";
1306 if (cOutKey.unit() != cInKey.
unit()) {
1313 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1326 void ProcessMosaic::AddDefaultBandBinGroup() {
1327 Pvl *outLab = OutputCubes[0]->label();
1331 int iOutBands = OutputCubes[0]->bandCount();
1332 int iOutBandsTotal = iOutBands;
1334 if (m_trackingEnabled) {
1337 else if (m_imageOverlay == AverageImageWithMosaic) {
1343 for (
int i=0; i<iOutBands; i++) {
1347 if (m_imageOverlay == AverageImageWithMosaic) {
1348 for (
int i=iOutBands; i<iOutBandsTotal; i++) {
1349 cOutKey +=
"NA_Count";
1353 if (m_trackingEnabled) {
1354 cOutKey +=
"TRACKING";
1359 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1366 int ProcessMosaic::GetBandIndex(
bool inputFile) {
1367 bool bFound =
false;
1373 cPvlLabel = *(InputCubes[0]->label());
1374 if (m_bandPriorityBandNumber <= InputCubes[0]->bandCount() &&
1375 m_bandPriorityBandNumber > 0) {
1376 iBandIndex = m_bandPriorityBandNumber;
1381 cPvlLabel = *(OutputCubes[0]->label());
1382 if (m_bandPriorityBandNumber <= OutputCubes[0]->bandCount() &&
1383 m_bandPriorityBandNumber > 0) {
1384 iBandIndex = m_bandPriorityBandNumber;
1412 if (!m_bandPriorityBandNumber) {
1414 if (cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).hasKeyword(m_bandPriorityKeyName)) {
1415 cKeyName = cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).findKeyword(m_bandPriorityKeyName);
1417 int iSize = cKeyName.
size();
1418 for (
int i = 0; i < iSize; i++) {
1419 if (m_bandPriorityKeyValue.toUpper() == cKeyName[i].toUpper()) {
1429 QString msg =
"Invalid Band / Key Name, Value ";
1450 void ProcessMosaic::BandComparison(
int iss,
int isl,
int isb,
int ins,
int inl,
int inb,
1451 int bandPriorityInputBandNumber,
int bandPriorityOutputBandNumber,
int index) {
1454 Portal cIportal(ins, 1, InputCubes[0]->pixelType());
1455 Portal cOportal(ins, 1, OutputCubes[0]->pixelType());
1456 Portal origPortal(ins, 1, OutputCubes[0]->pixelType());
1459 int iOriginBand = OutputCubes[0]->bandCount();
1461 for (
int iIL = isl, iOL = m_osl; iIL < isl + inl; iIL++, iOL++) {
1463 cIportal.
SetPosition(iss, iIL, bandPriorityInputBandNumber);
1464 InputCubes[0]->read(cIportal);
1466 cOportal.
SetPosition(m_oss, iOL, bandPriorityOutputBandNumber);
1467 OutputCubes[0]->read(cOportal);
1470 OutputCubes[0]->read(origPortal);
1473 for (
int iPixel = 0; iPixel < cOportal.
size(); iPixel++) {
1475 (m_placeHighSatPixels &&
IsHighPixel(cIportal[iPixel])) ||
1476 (m_placeLowSatPixels &&
IsLowPixel(cIportal[iPixel])) ||
1477 (m_placeNullPixels &&
IsNullPixel(cIportal[iPixel]))) {
1478 origPortal[iPixel] = index;
1483 (m_bandPriorityUseMaxValue ==
false && cIportal[iPixel] < cOportal[iPixel]) ||
1484 (m_bandPriorityUseMaxValue ==
true && cIportal[iPixel] > cOportal[iPixel])) {
1485 origPortal[iPixel] = index;
1490 OutputCubes[0]->write(origPortal);
1500 void ProcessMosaic::BandPriorityWithNoTracking(
int iss,
int isl,
int isb,
int ins,
int inl,
1501 int inb,
int bandPriorityInputBandNumber,
1502 int bandPriorityOutputBandNumber) {
1507 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
1508 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
1509 Portal resultsPortal ( ins, 1, OutputCubes[0]->pixelType() );
1512 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1513 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1515 for (
int inLine = isl, outLine = m_osl; inLine < isl + inl; inLine++, outLine++) {
1517 iComparePortal.
SetPosition(iss, inLine, bandPriorityInputBandNumber);
1518 InputCubes[0]->read(iComparePortal);
1520 oComparePortal.
SetPosition(m_oss, outLine, bandPriorityOutputBandNumber);
1521 OutputCubes[0]->read(oComparePortal);
1523 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1524 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1526 bool inCopy =
false;
1528 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1529 resultsPortal[iPixel] =
false;
1530 if (m_createOutputMosaic) {
1531 resultsPortal[iPixel] =
true;
1535 if ( (m_bandPriorityUseMaxValue ==
false &&
1536 iComparePortal[iPixel] < oComparePortal[iPixel]) ||
1537 (m_bandPriorityUseMaxValue ==
true &&
1538 iComparePortal[iPixel] > oComparePortal[iPixel]) ) {
1539 resultsPortal[iPixel] =
true;
1544 resultsPortal[iPixel] =
true;
1549 for (
int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
1552 InputCubes[0]->read(iPortal);
1555 OutputCubes[0]->read(oPortal);
1557 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1558 if (resultsPortal[iPixel]) {
1559 if (m_createOutputMosaic) {
1560 oPortal[iPixel] = iPortal[iPixel];
1563 (m_placeHighSatPixels &&
IsHighPixel(iPortal[iPixel]) ) ||
1564 (m_placeLowSatPixels &&
IsLowPixel (iPortal[iPixel]) ) ||
1565 (m_placeNullPixels &&
IsNullPixel(iPortal[iPixel]) ) ) {
1566 oPortal[iPixel] = iPortal[iPixel];
1570 oPortal[iPixel] = iPortal[iPixel];
1573 OutputCubes[0]->write(oPortal);
1591 int ProcessMosaic::GetIndexOffsetByPixelType() {
1594 switch (
SizeOf(OutputCubes[0]->pixelType())) {
1596 iOffset = VALID_MIN1;
1600 iOffset = VALID_MIN2;
1604 iOffset = FLOAT_STORE_INT_PRECISELY_MIN_VALUE;
1623 int ProcessMosaic::GetOriginDefaultByPixelType() {
1626 switch (
SizeOf(OutputCubes[0]->pixelType())) {
1640 QString msg =
"ProcessMosaic::GetOriginDefaultByPixelType - Invalid Pixel Type";
1656 void ProcessMosaic::ResetOriginBand() {
1657 int iBand = OutputCubes[0]->bandCount();
1658 int iLines = OutputCubes[0]->lineCount();
1659 int iSample = OutputCubes[0]->sampleCount();
1661 int iDefault = GetOriginDefaultByPixelType();
1663 Portal origPortal(iSample, 1, OutputCubes[0]->pixelType());
1665 for (
int i = 1; i <= iLines; i++) {
1667 OutputCubes[0]->read(origPortal);
1668 for (
int iPixel = 0; iPixel < origPortal.
size(); iPixel++) {
1669 origPortal[iPixel] = (float)(iDefault);
1671 OutputCubes[0]->write(origPortal);
1686 bool ProcessMosaic::GetTrackStatus() {
1688 Pvl *cPvlOut = OutputCubes[0]->label();
1690 bool bTableExists =
false;
1691 int iNumObjs = cPvlOut->
objects();
1696 for (
int i = 0; i < iNumObjs; i++) {
1697 cPvlObj = cPvlOut->
object(i);
1698 if (cPvlObj.
hasKeyword(
"Name", Pvl::Traverse)) {
1700 if (cNameKey[0] == TRACKING_TABLE_NAME) {
1701 bTableExists =
true;
1707 return bTableExists;
PvlObject & object(const int index)
Return the object at the specified index.
int Records() const
Returns the number of records.
int size() const
Returns the number of values stored in this keyword.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
File name manipulation and expansion.
Buffer for containing a two dimensional section of an image.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
bool IsLowPixel(const double d)
Returns if the input pixel is one of the low saturation types.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
int toInt(const QString &string)
Global function to convert from a string to an integer.
ImageOverlay
Enumeration for different Mosaic priorities (input, mosaic, band)
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
int RecordSize() const
Returns the number of bytes per record.
int RecordSize() const
Returns the number of bytes per record.
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
QString name() const
Returns the keyword name.
int objects() const
Returns the number of objects.
A single keyword-value pair.
QString unit(const int index=0) const
Returns the units of measurement of the element of the array of values for the object at the specifie...
bool IsSpecial(const double d)
Returns if the input pixel is special.
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Container for cube-like labels.
void SetPosition(const double sample, const double line, const int band)
Sets the line and sample position of the buffer.
void setUnits(QString units)
Sets the unit of measure for all current values if any exist.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
Class for storing Table blobs information.
int size() const
Returns the total number of pixels in the shape buffer.
bool IsHighPixel(const double d)
Returns if the input pixel is one of the high saturation types.
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Class for storing an Isis::Table's field information.
Contains Pvl Groups and Pvl Objects.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
QString name() const
Returns the container name.
IO Handler for Isis Cubes.