41 const char *ProcessMosaic::TRACKING_TABLE_NAME =
"InputImages";
48 ProcessMosaic::ProcessMosaic() {
50 SetBandBinMatch(
true);
53 m_trackingEnabled =
false;
54 m_trackingCube = NULL;
55 m_createOutputMosaic =
false;
56 m_bandPriorityBandNumber = 0;
57 m_bandPriorityKeyName =
"";
58 m_bandPriorityKeyValue =
"";
59 m_bandPriorityUseMaxValue =
false;
62 m_placeHighSatPixels =
false;
63 m_placeLowSatPixels =
false;
64 m_placeNullPixels =
false;
67 m_imageOverlay = PlaceImagesOnTop;
69 m_enforceMatchDEM =
false;
86 ProcessMosaic::~ProcessMosaic() {
88 m_trackingCube->close();
89 delete m_trackingCube;
90 m_trackingCube = NULL;
121 void ProcessMosaic::StartProcess(
const int &os,
const int &ol,
const int &ob) {
123 if ((OutputCubes.size() != 1) || (InputCubes.size() != 1)) {
124 QString m =
"You must specify exactly one input and one output cube";
128 bool bTrackExists =
false;
129 if (!m_createOutputMosaic) {
130 bTrackExists = GetTrackStatus();
131 if (m_trackingEnabled &&
132 !(OutputCubes[0]->hasGroup(
"Tracking") || OutputCubes[0]->hasTable(
"InputImages"))) {
133 QString m =
"Cannot enable tracking while adding to a mosaic without tracking ";
134 m +=
"information. Confirm that your mosaic was originally created with tracking enabled.";
147 ins = (int)InputCubes[0]->sampleCount();
150 inl = (int)InputCubes[0]->lineCount();
153 inb = (int)InputCubes[0]->bandCount();
162 iss = iss - m_oss + 1;
163 ins = ins + m_oss - 1;
168 isl = isl - m_osl + 1;
169 inl = inl + m_osl - 1;
173 if ((m_oss + ins - 1) > OutputCubes[0]->sampleCount()) {
174 ins = OutputCubes[0]->sampleCount() - m_oss + 1;
177 if ((m_osl + inl - 1) > OutputCubes[0]->lineCount()) {
178 inl = OutputCubes[0]->lineCount() - m_osl + 1;
181 PvlGroup imgPosition(
"ImageLocation");
182 imgPosition +=
PvlKeyword(
"File", InputCubes[0]->fileName());
185 m_imagePositions += imgPosition;
188 if ((ins < 1) || (inl < 1)) {
189 QString m =
"The input cube does not overlap the mosaic";
195 isb = isb - m_osb + 1;
196 inb = inb + m_osb - 1;
200 p_progress->SetMaximumSteps(
201 (
int)InputCubes[0]->lineCount() * (
int)InputCubes[0]->bandCount());
202 p_progress->CheckStatus();
211 if (m_trackingEnabled) {
212 if (!(m_imageOverlay == UseBandPlacementCriteria ||
213 ((m_imageOverlay == PlaceImagesOnTop || m_imageOverlay == PlaceImagesBeneath) &&
215 (OutputCubes[0]->bandCount()) == 1) ||
216 (m_imageOverlay == PlaceImagesOnTop && m_placeHighSatPixels && m_placeLowSatPixels &&
217 m_placeNullPixels)) ){
218 QString m =
"Tracking cannot be True for multi-band Mosaic with ontop or beneath priority";
225 Pvl *inLab = InputCubes[0]->label();
227 if (m_enforceMatchDEM){
228 MatchDEMShapeModel();
232 if (m_enforceBandBinMatch) {
233 Pvl *outLab = OutputCubes[0]->label();
235 if (inLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
238 if (!m_createOutputMosaic && outLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
239 MatchBandBinGroup(isb, inb);
243 AddBandBinGroup(isb);
248 QString m =
"Match BandBin cannot be True when the Image does not have the BandBin group";
254 if (m_createOutputMosaic) {
255 if (inLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
256 AddBandBinGroup(isb);
259 AddDefaultBandBinGroup();
267 m_trackingEnabled =
true;
271 int bandPriorityInputBandNumber = -1;
272 int bandPriorityOutputBandNumber = -1;
273 if (m_imageOverlay == UseBandPlacementCriteria ) {
274 bandPriorityInputBandNumber = GetBandIndex(
true);
275 bandPriorityOutputBandNumber = GetBandIndex(
false);
279 int iIndex = VALID_MINUI4;
281 if (OutputCubes[0]->hasGroup(
"Tracking") && !m_createOutputMosaic) {
282 m_trackingEnabled =
true;
287 if (m_trackingEnabled) {
290 if (!m_trackingCube) {
291 m_trackingCube =
new Cube;
294 if (m_createOutputMosaic) {
297 m_trackingCube->
setPixelType(PixelType::UnsignedInteger);
300 m_trackingCube->setDimensions(OutputCubes[0]->sampleCount(),
301 OutputCubes[0]->lineCount(),
306 m_trackingCube->create(
FileName(OutputCubes[0]->fileName()).path()
307 +
"/" + trackingBase +
"_tracking.cub");
310 Pvl *mosaicLabel = OutputCubes[0]->label();
311 PvlGroup trackingFileGroup(
"Tracking");
313 trackingFileName.
setValue(trackingBase +
"_tracking.cub");
314 trackingFileGroup.
addKeyword(trackingFileName);
315 mosaicLabel->
findObject(
"IsisCube").addGroup(trackingFileGroup);
318 Pvl *trackingLabel = m_trackingCube->label();
321 trackBand +=
"TRACKING";
323 trackingLabel->
findObject(
"IsisCube").addGroup(bandBin);
332 if ( OutputCubes[0]->hasGroup(
"Tracking") ) {
333 QString trackingPath =
FileName(OutputCubes[0]->fileName()).
path();
334 QString trackingFile = OutputCubes[0]->group(
"Tracking").findKeyword(
"FileName")[0];
335 m_trackingCube->open(trackingPath +
"/" + trackingFile,
"rw");
340 table =
new Table(TRACKING_TABLE_NAME, m_trackingCube->fileName());
344 QString msg =
"Unable to find Tracking Table in " + m_trackingCube->fileName() +
".";
351 QString msg =
"Tracking cannot be enabled when adding to an existing mosaic " 352 "that does not already have a tracking cube. Mosaics with a tracking band must " 353 "have the tracking band extracted into an external tracking cube.";
360 SerialNumber::Compose(*(InputCubes[0])));
363 if (m_trackingCube->hasTable(Isis::trackingTableName)) {
364 m_trackingCube->deleteBlob(
"Table", Isis::trackingTableName);
367 m_trackingCube->write(table);
371 else if (m_imageOverlay == AverageImageWithMosaic && m_createOutputMosaic) {
375 m_onb = OutputCubes[0]->bandCount();
377 if (m_trackingEnabled) {
380 if (m_imageOverlay == UseBandPlacementCriteria && !m_createOutputMosaic) {
381 BandComparison(iss, isl, ins, inl,
382 bandPriorityInputBandNumber, bandPriorityOutputBandNumber, iIndex);
385 else if (m_imageOverlay == AverageImageWithMosaic) {
388 QString msg =
"The mosaic cube needs a count band.";
394 if (m_imageOverlay == UseBandPlacementCriteria && !m_trackingEnabled ) {
395 BandPriorityWithNoTracking(iss, isl, isb, ins, inl, inb, bandPriorityInputBandNumber,
396 bandPriorityOutputBandNumber);
400 Portal iPortal(ins, 1, InputCubes[0]->pixelType());
401 Portal oPortal(ins, 1, OutputCubes[0]->pixelType());
402 Portal countPortal(ins, 1, OutputCubes[0]->pixelType());
403 Portal trackingPortal(ins, 1, PixelType::UnsignedInteger);
405 for (
int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
406 for (
int il = isl, ol = m_osl; il < isl + inl; il++, ol++) {
409 InputCubes[0]->read(iPortal);
412 OutputCubes[0]->read(oPortal);
414 if (m_trackingEnabled) {
416 m_trackingCube->read(trackingPortal);
418 else if (m_imageOverlay == AverageImageWithMosaic) {
420 OutputCubes[0]->read(countPortal);
423 bool bChanged =
false;
425 for (
int pixel = 0; pixel < oPortal.
size(); pixel++) {
428 if (m_createOutputMosaic) {
429 oPortal[pixel] = iPortal[pixel];
430 if (m_trackingEnabled) {
431 trackingPortal[pixel] = iIndex;
434 else if (m_imageOverlay == AverageImageWithMosaic) {
436 countPortal[pixel]=1;
442 else if (m_trackingEnabled && m_imageOverlay == UseBandPlacementCriteria) {
443 int iPixelOrigin = qRound(trackingPortal[pixel]);
445 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
446 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
447 iComparePortal.
SetPosition(iss, il, bandPriorityInputBandNumber);
448 InputCubes[0]->read(iComparePortal);
449 oComparePortal.
SetPosition(m_oss, ol, bandPriorityOutputBandNumber);
450 OutputCubes[0]->read(oComparePortal);
452 if (iPixelOrigin == iIndex) {
455 ( (!m_bandPriorityUseMaxValue &&
456 iComparePortal[pixel] < oComparePortal[pixel]) ||
457 (m_bandPriorityUseMaxValue &&
458 iComparePortal[pixel] > oComparePortal[pixel]) ) ) {
461 ( m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel]) ) ||
462 ( m_placeLowSatPixels &&
IsLowPixel (iPortal[pixel]) ) ||
463 ( m_placeNullPixels &&
IsNullPixel(iPortal[pixel]) ) ){
464 oPortal[pixel] = iPortal[pixel];
470 ( m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel]) ) ||
471 ( m_placeLowSatPixels &&
IsLowPixel (iPortal[pixel]) ) ||
472 ( m_placeNullPixels &&
IsNullPixel(iPortal[pixel]) ) ) {
473 oPortal[pixel] = iPortal[pixel];
480 else if (m_imageOverlay == PlaceImagesOnTop) {
483 (m_placeHighSatPixels &&
IsHighPixel(iPortal[pixel])) ||
484 (m_placeLowSatPixels &&
IsLowPixel(iPortal[pixel])) ||
485 (m_placeNullPixels &&
IsNullPixel(iPortal[pixel]))) {
486 oPortal[pixel] = iPortal[pixel];
487 if (m_trackingEnabled) {
488 trackingPortal[pixel] = iIndex;
494 else if (m_imageOverlay == AverageImageWithMosaic) {
495 bChanged |= ProcessAveragePriority(pixel, iPortal, oPortal, countPortal);
498 else if (m_imageOverlay == PlaceImagesBeneath) {
500 oPortal[pixel] = iPortal[pixel];
503 if (m_trackingEnabled) {
504 trackingPortal[pixel] = iIndex;
511 if (m_trackingEnabled) {
512 m_trackingCube->write(trackingPortal);
514 if (m_imageOverlay == AverageImageWithMosaic) {
515 OutputCubes[0]->write(countPortal);
518 OutputCubes[0]->write(oPortal);
519 p_progress->CheckStatus();
523 if (m_trackingCube) {
524 m_trackingCube->close();
525 delete m_trackingCube;
526 m_trackingCube = NULL;
534 void ProcessMosaic::EndProcess() {
535 if (m_trackingCube) {
536 m_trackingCube->close();
537 delete m_trackingCube;
538 m_trackingCube = NULL;
540 Process::EndProcess();
550 return m_imagePositions;
591 Cube *ProcessMosaic::SetInputCube(
const QString ¶meter,
592 const int ss,
const int sl,
const int sb,
593 const int ns,
const int nl,
const int nb) {
596 if (InputCubes.size() > 0) {
597 QString m =
"You must specify exactly one input cube";
608 Cube *cInCube = Process::SetInputCube(parameter);
611 Pvl *cInPvl = InputCubes[0]->label();
612 if (cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).hasKeyword(
"Bands")) {
613 PvlKeyword &cBandKey = cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).findKeyword(
"Bands");
614 QString sStr(cBandKey[0]);
615 if (
toInt(sStr) < nb) {
616 QString m =
"The parameter number of input bands exceeds the actual number of bands in the " 661 Cube *ProcessMosaic::SetInputCube(
const QString &fname,
663 const int ss,
const int sl,
const int sb,
664 const int ns,
const int nl,
const int nb) {
667 if (InputCubes.size() > 0) {
668 QString m =
"You must specify exactly one input cube";
679 Cube *cInCube = Process::SetInputCube(fname, att);
682 Pvl *cInPvl = InputCubes[0]->label();
683 if (cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).hasKeyword(
"Bands")) {
684 PvlKeyword &cBandKey = cInPvl->
findGroup(
"Dimensions", Pvl::Traverse).findKeyword(
"Bands");
685 QString sStr(cBandKey[0]);
686 if (
toInt(sStr) < nb) {
687 QString m =
"The parameter number of input bands exceeds the actual number of bands in the input cube";
709 Cube *ProcessMosaic::SetOutputCube(
const QString &psParameter) {
712 if (OutputCubes.size() > 0) {
713 QString m =
"You must specify exactly one output cube";
721 QString fname = Application::GetUserInterface().GetFileName(psParameter);
722 cube->
open(fname,
"rw");
729 if (m_createOutputMosaic) {
731 if (outLab->
findObject(
"IsisCube").hasGroup(
"BandBin")) {
732 outLab->
findObject(
"IsisCube").deleteGroup(
"BandBin");
745 void ProcessMosaic::SetBandBinMatch(
bool enforceBandBinMatch) {
746 m_enforceBandBinMatch = enforceBandBinMatch;
753 void ProcessMosaic::SetBandKeyword(QString bandPriorityKeyName, QString bandPriorityKeyValue) {
754 m_bandPriorityKeyName = bandPriorityKeyName;
755 m_bandPriorityKeyValue = bandPriorityKeyValue;
762 void ProcessMosaic::SetBandNumber(
int bandPriorityBandNumber) {
763 m_bandPriorityBandNumber = bandPriorityBandNumber;
771 void ProcessMosaic::SetBandUseMaxValue(
bool useMax) {
772 m_bandPriorityUseMaxValue = useMax;
784 void ProcessMosaic::SetCreateFlag(
bool createOutputMosaic) {
785 m_createOutputMosaic = createOutputMosaic;
793 void ProcessMosaic::SetHighSaturationFlag(
bool placeHighSatPixels) {
794 m_placeHighSatPixels = placeHighSatPixels;
798 void ProcessMosaic::SetImageOverlay(ImageOverlay placement) {
799 m_imageOverlay = placement;
807 void ProcessMosaic::SetLowSaturationFlag(
bool placeLowSatPixels) {
808 m_placeLowSatPixels = placeLowSatPixels;
815 void ProcessMosaic::SetMatchDEM(
bool matchDEM) {
816 m_enforceMatchDEM = matchDEM;
824 void ProcessMosaic::SetNullFlag(
bool placeNullPixels) {
825 m_placeNullPixels = placeNullPixels;
829 void ProcessMosaic::SetTrackFlag(
bool trackingEnabled) {
830 m_trackingEnabled = trackingEnabled;
837 bool ProcessMosaic::GetHighSaturationFlag()
const {
838 return m_placeHighSatPixels;
846 return m_imageOverlay;
853 bool ProcessMosaic::GetLowSaturationFlag()
const {
854 return m_placeLowSatPixels;
861 bool ProcessMosaic::GetNullFlag()
const {
862 return m_placeNullPixels;
869 bool ProcessMosaic::GetTrackFlag()
const {
870 return m_trackingEnabled;
877 int ProcessMosaic::GetInputStartLineInMosaic()
const {
885 int ProcessMosaic::GetInputStartSampleInMosaic()
const {
893 int ProcessMosaic::GetInputStartBandInMosaic()
const {
905 switch (imageOverlay) {
906 case PlaceImagesOnTop:
910 case PlaceImagesBeneath:
914 case UseBandPlacementCriteria:
918 case AverageImageWithMosaic:
922 case NumImageOverlayOptions:
928 "Cannot convert overlay [" +
toString((
int)imageOverlay) +
"] to a string",
941 QString imageOverlayStringUpper = imageOverlayString.toUpper();
942 for (
int i = 0; i < NumImageOverlayOptions; i++) {
943 if (OverlayToString((
ImageOverlay)i).toUpper() == imageOverlayStringUpper)
948 "The text [" + imageOverlayString +
"] does not correspond to any known " 949 "image overlay modes (mosaic priorities)",
961 void ProcessMosaic::MatchDEMShapeModel() {
962 Pvl* inLabel = InputCubes[0]->label();
963 Pvl* outLabel = OutputCubes[0]->label();
965 if (outLabel->
findObject(
"IsisCube").hasGroup(
"Mosaic")) {
968 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
972 QString sShapeModel = inMosaicGrp.
findKeyword(
"ShapeModel")[0];
973 int found = sShapeModel.lastIndexOf(
"/");
975 sShapeModel.remove(0, found + 1);
977 if (sShapeModel == outShapeModelKey[0]) {
982 QString sErrMsg =
"Input and Mosaic DEM Shape Model do not match";
987 if (m_createOutputMosaic) {
988 if (inLabel->
findObject(
"IsisCube").hasGroup(
"Kernels")) {
989 QString sShapeModel =
990 inLabel->
findObject(
"IsisCube").findGroup(
"Kernels").findKeyword(
"ShapeModel")[0];
991 int found = sShapeModel.lastIndexOf(
"/");
993 sShapeModel.remove(0, found+1);
998 shapeModelKey += sShapeModel;
999 mosaicGrp += shapeModelKey;
1000 outIsisCubeObj += mosaicGrp;
1012 void ProcessMosaic::ResetCountBands()
1014 int iBand = OutputCubes[0]->bandCount();
1015 int iLines = OutputCubes[0]->lineCount();
1016 int iSample = OutputCubes[0]->sampleCount();
1018 Portal countPortal(iSample, 1, OutputCubes[0]->pixelType());
1019 int iStartCountBand = iBand/2 + 1;
1021 for (
int band=iStartCountBand; band<=iBand; band++) {
1022 for (
int i = 1; i <= iLines; i++) {
1024 OutputCubes[0]->read(countPortal);
1025 for (
int iPixel = 0; iPixel < countPortal.
size(); iPixel++) {
1026 countPortal[iPixel] = 0;
1028 OutputCubes[0]->write(countPortal);
1047 bool ProcessMosaic::ProcessAveragePriority(
int piPixel,
Portal& piPortal,
Portal& poPortal,
1050 bool bChanged=
false;
1052 int iCount = (int)countPortal[piPixel];
1053 double dNewDN = (poPortal[piPixel] * iCount + piPortal[piPixel]) / (iCount + 1);
1054 poPortal[piPixel] = dNewDN;
1055 countPortal[piPixel] =iCount +1;
1060 poPortal[piPixel] = piPortal[piPixel];
1061 countPortal[piPixel] = 1;
1065 else if (
IsSpecial(piPortal[piPixel])) {
1066 if ((m_placeHighSatPixels &&
IsHighPixel(piPortal[piPixel])) ||
1067 (m_placeLowSatPixels &&
IsLowPixel (piPortal[piPixel])) ||
1068 (m_placeNullPixels &&
IsNullPixel(piPortal[piPixel]))) {
1069 poPortal[piPixel] = piPortal[piPixel];
1070 countPortal[piPixel] = 0;
1089 void ProcessMosaic::MatchBandBinGroup(
int origIsb,
int &inb) {
1090 Pvl *inLab = InputCubes[0]->label();
1091 Pvl *outLab = OutputCubes[0]->label();
1096 QString msg =
"Pvl Group [BandBin] does not match between the input and output cubes";
1101 int isb = (origIsb - 1);
1102 int osb = (m_osb - 1);
1103 int iOutBandsHalf = OutputCubes[0]->bandCount()/2;
1105 for (
int i = 0; i < outBin.
keywords(); i++) {
1107 QString sOutName = outKey.
name();
1110 for (
int j = osb, k = isb; j < outKey.
size() && k < inKey.
size(); j++, k++) {
1111 if (outKey[j] ==
"NA") {
1112 outKey[j] = inKey[k];
1113 if (m_imageOverlay == AverageImageWithMosaic) {
1114 if (sOutName.contains(
"Filter") ||
1115 sOutName.contains(
"Name")) {
1116 outKey[j+iOutBandsHalf] = inKey[k] +
"_Count";
1119 outKey[j+iOutBandsHalf] =
"Avg_Count";
1123 else if (outKey[j] != inKey[k]) {
1124 QString msg =
"The input cube [" + inLab->
fileName() +
"] and the base mosaic values " 1125 "of the Pvl Group [BandBin] for Keyword [" + outKey.
name() +
"] do not " 1126 "match. Base mosaic value at index [" + QString::number(j) +
"] = " +
1127 outKey[j] +
". Input cube value at index [" + QString::number(k) +
"] = " 1128 + inKey[k] +
". **Note: use mapmos/automos MatchBandBin = false to " 1129 "override this check**";
1137 QString msg =
"Pvl Group [BandBin] In Keyword[" + inBin[i].
name() +
"] and Out Keyword[" +
1138 outBin[i].
name() +
"] does not match";
1143 int inputRange = InputCubes[0]->bandCount() - isb;
1144 int outputRange = OutputCubes[0]->bandCount() - osb;
1145 inb = min(inputRange, outputRange);
1160 void ProcessMosaic::AddBandBinGroup(
int origIsb) {
1161 Pvl *inLab = InputCubes[0]->label();
1162 Pvl *outLab = OutputCubes[0]->label();
1164 int iOutBands = OutputCubes[0]->bandCount();
1167 if (m_imageOverlay == AverageImageWithMosaic) {
1171 int isb = origIsb - 1;
1172 int osb = m_osb - 1;
1177 for (
int i = 0; i < cInBin.
keywords(); i++) {
1179 int iInKeySize = cInKey.
size();
1182 for (
int b = 0; b < osb; b++) {
1185 for (
int b = osb; b < iOutBands; b++) {
1186 if (isb < iInKeySize) {
1187 cOutKey += cInKey[isb++];
1195 if (m_imageOverlay == AverageImageWithMosaic) {
1197 int iTotalOutBands = OutputCubes[0]->bandCount();
1199 int iOutStartBand = iOutBands + osb;
1200 QString sKeyName = cInKey.
name();
1201 bool bFilterKey =
false;
1202 if (sKeyName.contains(
"Filter") ||
1203 sKeyName.contains(
"Original") ||
1204 sKeyName.contains(
"Name")) {
1207 for (
int ob=iOutBands; ob<iTotalOutBands; ob++) {
1208 if (isb < iInKeySize && ob >= iOutStartBand) {
1210 cOutKey += cInKey[isb++] +
"_Count";
1225 if (cOutKey.unit() != cInKey.
unit()) {
1232 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1245 void ProcessMosaic::AddDefaultBandBinGroup() {
1246 Pvl *outLab = OutputCubes[0]->label();
1250 int iOutBands = OutputCubes[0]->bandCount();
1251 int iOutBandsTotal = iOutBands;
1253 if (m_trackingEnabled) {
1256 else if (m_imageOverlay == AverageImageWithMosaic) {
1262 for (
int i=0; i<iOutBands; i++) {
1266 if (m_imageOverlay == AverageImageWithMosaic) {
1267 for (
int i=iOutBands; i<iOutBandsTotal; i++) {
1268 cOutKey +=
"NA_Count";
1272 if (m_trackingEnabled) {
1273 cOutKey +=
"TRACKING";
1278 outLab->
findObject(
"IsisCube").addGroup(cOutBin);
1285 int ProcessMosaic::GetBandIndex(
bool inputFile) {
1286 bool bFound =
false;
1292 cPvlLabel = *(InputCubes[0]->label());
1293 if (m_bandPriorityBandNumber <= InputCubes[0]->bandCount() &&
1294 m_bandPriorityBandNumber > 0) {
1295 iBandIndex = m_bandPriorityBandNumber;
1300 cPvlLabel = *(OutputCubes[0]->label());
1301 if (m_bandPriorityBandNumber <= OutputCubes[0]->bandCount() &&
1302 m_bandPriorityBandNumber > 0) {
1303 iBandIndex = m_bandPriorityBandNumber;
1309 if (!m_bandPriorityBandNumber) {
1311 if (cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).hasKeyword(m_bandPriorityKeyName)) {
1312 cKeyName = cPvlLabel.
findGroup(
"BandBin", Pvl::Traverse).findKeyword(m_bandPriorityKeyName);
1314 int iSize = cKeyName.
size();
1315 for (
int i = 0; i < iSize; i++) {
1316 if (m_bandPriorityKeyValue.toUpper() == cKeyName[i].toUpper()) {
1324 QString msg =
"Invalid Band / Key Name, Value ";
1348 void ProcessMosaic::BandComparison(
int iss,
int isl,
int ins,
int inl,
1349 int bandPriorityInputBandNumber,
int bandPriorityOutputBandNumber,
int index) {
1352 Portal cIportal(ins, 1, InputCubes[0]->pixelType());
1353 Portal cOportal(ins, 1, OutputCubes[0]->pixelType());
1354 Portal trackingPortal(ins, 1, PixelType::UnsignedInteger);
1356 for (
int iIL = isl, iOL = m_osl; iIL < isl + inl; iIL++, iOL++) {
1358 cIportal.
SetPosition(iss, iIL, bandPriorityInputBandNumber);
1359 InputCubes[0]->read(cIportal);
1361 cOportal.
SetPosition(m_oss, iOL, bandPriorityOutputBandNumber);
1362 OutputCubes[0]->read(cOportal);
1365 m_trackingCube->read(trackingPortal);
1368 for (
int iPixel = 0; iPixel < cOportal.
size(); iPixel++) {
1369 if ((m_placeHighSatPixels &&
IsHighPixel(cIportal[iPixel])) ||
1370 (m_placeLowSatPixels &&
IsLowPixel(cIportal[iPixel])) ||
1371 (m_placeNullPixels &&
IsNullPixel(cIportal[iPixel]))) {
1372 trackingPortal[iPixel] = index;
1377 (m_bandPriorityUseMaxValue ==
false && cIportal[iPixel] < cOportal[iPixel]) ||
1378 (m_bandPriorityUseMaxValue ==
true && cIportal[iPixel] > cOportal[iPixel])) {
1379 trackingPortal[iPixel] = index;
1384 m_trackingCube->write(trackingPortal);
1394 void ProcessMosaic::BandPriorityWithNoTracking(
int iss,
int isl,
int isb,
int ins,
int inl,
1395 int inb,
int bandPriorityInputBandNumber,
1396 int bandPriorityOutputBandNumber) {
1401 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
1402 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
1403 Portal resultsPortal ( ins, 1, OutputCubes[0]->pixelType() );
1406 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1407 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1409 for (
int inLine = isl, outLine = m_osl; inLine < isl + inl; inLine++, outLine++) {
1411 iComparePortal.
SetPosition(iss, inLine, bandPriorityInputBandNumber);
1412 InputCubes[0]->read(iComparePortal);
1414 oComparePortal.
SetPosition(m_oss, outLine, bandPriorityOutputBandNumber);
1415 OutputCubes[0]->read(oComparePortal);
1417 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1418 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1420 bool inCopy =
false;
1422 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1423 resultsPortal[iPixel] =
false;
1424 if (m_createOutputMosaic) {
1425 resultsPortal[iPixel] =
true;
1429 if ( (m_bandPriorityUseMaxValue ==
false &&
1430 iComparePortal[iPixel] < oComparePortal[iPixel]) ||
1431 (m_bandPriorityUseMaxValue ==
true &&
1432 iComparePortal[iPixel] > oComparePortal[iPixel]) ) {
1433 resultsPortal[iPixel] =
true;
1438 resultsPortal[iPixel] =
true;
1443 for (
int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
1446 InputCubes[0]->read(iPortal);
1449 OutputCubes[0]->read(oPortal);
1451 for (
int iPixel = 0; iPixel < ins; iPixel++) {
1452 if (resultsPortal[iPixel]) {
1453 if (m_createOutputMosaic) {
1454 oPortal[iPixel] = iPortal[iPixel];
1457 (m_placeHighSatPixels &&
IsHighPixel(iPortal[iPixel]) ) ||
1458 (m_placeLowSatPixels &&
IsLowPixel (iPortal[iPixel]) ) ||
1459 (m_placeNullPixels &&
IsNullPixel(iPortal[iPixel]) ) ) {
1460 oPortal[iPixel] = iPortal[iPixel];
1464 oPortal[iPixel] = iPortal[iPixel];
1467 OutputCubes[0]->write(oPortal);
1486 int ProcessMosaic::GetOriginDefaultByPixelType() {
1489 switch (
SizeOf(OutputCubes[0]->pixelType())) {
1503 QString msg =
"ProcessMosaic::GetOriginDefaultByPixelType - Invalid Pixel Type";
1520 bool ProcessMosaic::GetTrackStatus() {
1522 Pvl *cPvlOut = OutputCubes[0]->label();
1524 bool bGroupExists =
false;
1528 if (cPvlOut->
hasGroup(
"Tracking")) {
1529 bGroupExists =
true;
1532 return bGroupExists;
int keywords() const
Returns the number of keywords contained in the PvlContainer.
QString path() const
Returns the path of the file name.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
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...
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.
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.
Namespace for the standard library.
Table toTable()
Constrcts and returns a Table object based on values in m_fileList.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
ImageOverlay
Enumeration for different Mosaic priorities (input, mosaic, band)
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
int size() const
Returns the total number of pixels in the shape buffer.
QString name() const
Returns the container name.
int size() const
Returns the number of values stored in this keyword.
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
A single keyword-value pair.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
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.
unsigned int fileNameToPixel(FileName file, QString serialNumber)
Returns the pixel value of the filename/serialnumber combination.
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.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Class for storing Table blobs information.
Table to store tracking information for a mosaic.
bool IsHighPixel(const double d)
Returns if the input pixel is one of the high saturation types.
QString fileName() const
Returns the filename used to initialise the Pvl object.
QString name() const
Returns the keyword name.
Namespace for ISIS/Bullet specific routines.
bool IsNullPixel(const double d)
Returns if the input pixel is null.
void setValue(QString value, QString unit="")
Sets new values.
Contains Pvl Groups and Pvl Objects.
FileName removeExtension() const
Removes all extensions in the file name.
IO Handler for Isis Cubes.