Isis 3 Programmer Reference
ProcessMosaic.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Preference.h"
8
9#include "Application.h"
10#include "IException.h"
11#include "IString.h"
12#include "Portal.h"
13#include "ProcessMosaic.h"
14#include "Pvl.h"
15#include "SerialNumber.h"
16#include "SpecialPixel.h"
17#include "Table.h"
18#include "TrackingTable.h"
19
20using namespace std;
21
22namespace Isis {
26 const char *ProcessMosaic::TRACKING_TABLE_NAME = "InputImages";
27
34 // Set the BandBin Match
35 SetBandBinMatch(true);
36
37 // Initialize the structure Track Info
38 m_trackingEnabled = false;
39 m_trackingCube = NULL;
40 m_createOutputMosaic = false;
41 m_bandPriorityBandNumber = 0;
42 m_bandPriorityKeyName = "";
43 m_bandPriorityKeyValue = "";
44 m_bandPriorityUseMaxValue = false;
45
46 // Initialize the Special Pixel Flags
47 m_placeHighSatPixels = false;
48 m_placeLowSatPixels = false;
49 m_placeNullPixels = false;
50
51 // Default Priority OnTop
52 m_imageOverlay = PlaceImagesOnTop;
53
54 m_enforceMatchDEM = false;
55
56 // Initialize the data members
57 m_iss = -1;
58 m_isl = -1;
59 m_isb = -1;
60 m_ins = -1;
61 m_inl = -1;
62 m_inb = -1;
63 m_oss = -1;
64 m_osl = -1;
65 m_osb = -1;
66 m_onb = -1;
67 }
68
69
78
79
106 void ProcessMosaic::StartProcess(const int &os, const int &ol, const int &ob) {
107 // Error checks ... there must be one input and one output
108 if ((OutputCubes.size() != 1) || (InputCubes.size() != 1)) {
109 QString m = "You must specify exactly one input and one output cube";
110 throw IException(IException::Programmer, m, _FILEINFO_);
111 }
112
113 bool bTrackExists = false;
114 if (!m_createOutputMosaic) {
115 bTrackExists = GetTrackStatus();
116 if (m_trackingEnabled &&
117 !(OutputCubes[0]->hasGroup("Tracking") || OutputCubes[0]->hasTable("InputImages"))) {
118 QString m = "Cannot enable tracking while adding to a mosaic without tracking ";
119 m += "information. Confirm that your mosaic was originally created with tracking enabled.";
120 throw IException(IException::User, m, _FILEINFO_);
121 }
122 }
123
124 int ins = m_ins;
125 int inl = m_inl;
126 int inb = m_inb;
127 int iss = m_iss;
128 int isl = m_isl;
129 int isb = m_isb;
130
131 if (ins == -1)
132 ins = (int)InputCubes[0]->sampleCount();
133
134 if (inl == -1)
135 inl = (int)InputCubes[0]->lineCount();
136
137 if (inb == -1)
138 inb = (int)InputCubes[0]->bandCount();
139
140 // Adjust the input sub-area if it overlaps any edge of the output cube
141 m_oss = os;
142 m_osl = ol;
143 m_osb = ob;
144
145 // Left edge
146 if (m_oss < 1) {
147 iss = iss - m_oss + 1;
148 ins = ins + m_oss - 1;
149 m_oss = 1;
150 }
151 // Top edge
152 if (m_osl < 1) {
153 isl = isl - m_osl + 1;
154 inl = inl + m_osl - 1;
155 m_osl = 1;
156 }
157 // Right edge
158 if ((m_oss + ins - 1) > OutputCubes[0]->sampleCount()) {
159 ins = OutputCubes[0]->sampleCount() - m_oss + 1;
160 }
161 // Bottom edge
162 if ((m_osl + inl - 1) > OutputCubes[0]->lineCount()) {
163 inl = OutputCubes[0]->lineCount() - m_osl + 1;
164 }
165
166 PvlGroup imgPosition("ImageLocation");
167 imgPosition += PvlKeyword("File", InputCubes[0]->fileName());
168 imgPosition += PvlKeyword("StartSample", toString(m_oss));
169 imgPosition += PvlKeyword("StartLine", toString(m_osl));
170 m_imagePositions += imgPosition;
171
172 // Tests for completly off the mosaic
173 if ((ins < 1) || (inl < 1)) {
174 QString m = "The input cube does not overlap the mosaic";
175 throw IException(IException::User, m, _FILEINFO_);
176 }
177
178 // Band Adjustments
179 if (m_osb < 1) {
180 isb = isb - m_osb + 1;
181 inb = inb + m_osb - 1;
182 m_osb = 1;
183 }
184
186 (int)InputCubes[0]->lineCount() * (int)InputCubes[0]->bandCount());
188
189 // Tracking is done for:
190 // (1) Band priority,
191 // (2) Ontop and Beneath priority with number of bands equal to 1,
192 // (3) Ontop priority with all the special pixel flags set to true. (All special pixel flags
193 // must be set to true in order to handle multiple bands since we need to force pixels
194 // from all bands in a single image to be copied to the mosaic with ontop priority so we
195 // don't have multiple input bands to track for any single pixel in our tracking band.)
196 if (m_trackingEnabled) {
197 if (!(m_imageOverlay == UseBandPlacementCriteria ||
198 ((m_imageOverlay == PlaceImagesOnTop || m_imageOverlay == PlaceImagesBeneath) &&
199 // tracking band was already created for Tracking=true
200 (OutputCubes[0]->bandCount()) == 1) ||
201 (m_imageOverlay == PlaceImagesOnTop && m_placeHighSatPixels && m_placeLowSatPixels &&
202 m_placeNullPixels)) ){
203 QString m = "Tracking cannot be True for multi-band Mosaic with ontop or beneath priority";
204 throw IException(IException::Programmer, m, _FILEINFO_);
205 }
206 }
207
208 // *******************************************************************************
209
210 Pvl *inLab = InputCubes[0]->label();
211 // Create / Match DEM Shape Model if bMatchDEM Flag is enabled
214 }
215
216 // Check to make sure the bandbins match if necessary
218 Pvl *outLab = OutputCubes[0]->label();
219
220 if (inLab->findObject("IsisCube").hasGroup("BandBin")) {
221 // Check to make sure the output cube has a bandbin group & make sure it
222 // matches the input cube bandbin group
223 if (!m_createOutputMosaic && outLab->findObject("IsisCube").hasGroup("BandBin")) {
224 MatchBandBinGroup(isb, inb);
225 }
226 // Otherwise copy the input cube bandbin to the output file
227 else {
228 AddBandBinGroup(isb);
229 }
230 }
231 // BandBin group is not found
232 else {
233 QString m = "Match BandBin cannot be True when the Image does not have the BandBin group";
234 throw IException(IException::Programmer, m, _FILEINFO_);
235 }
236 }
237 // Match BandBin set to false and CREATE and TRACKING is true
238 else {
239 if (m_createOutputMosaic) {
240 if (inLab->findObject("IsisCube").hasGroup("BandBin")) {
241 AddBandBinGroup(isb);
242 }
243 else {
245 }
246 }
247 }
248
249 // Even if the track flag is off, if the track table exists and "TRACKING" exists in bandbin
250 // group continue tracking
251 if (bTrackExists) {
252 m_trackingEnabled = true;
253 }
254
255 // We don't want to set the filename in the table unless the band info is valid
256 int bandPriorityInputBandNumber = -1;
257 int bandPriorityOutputBandNumber = -1;
258 if (m_imageOverlay == UseBandPlacementCriteria ) {
259 bandPriorityInputBandNumber = GetBandIndex(true);
260 bandPriorityOutputBandNumber = GetBandIndex(false);
261 }
262
263 // Set index of tracking image to the default offset of the Isis::UnsignedByte
264 int iIndex = VALID_MINUI4;
265 // Propogate tracking if adding to mosaic that was previouly tracked.
266 if (OutputCubes[0]->hasGroup("Tracking") && !m_createOutputMosaic) {
267 m_trackingEnabled = true;
268 }
269
270 // Create tracking cube if need-be, add bandbin group, and update tracking table. Add tracking
271 // group to mosaic cube.
272 if (m_trackingEnabled) {
273 TrackingTable *trackingTable;
274
275 if (!m_trackingCube) {
276 m_trackingCube = new Cube;
277
278 // A new mosaic cube is being created
279 if (m_createOutputMosaic) {
280
281 // Tracking cubes are always unsigned 4 byte integer
282 m_trackingCube->setPixelType(PixelType::UnsignedInteger);
283
284 // Tracking cube has the same number of lines and samples as the mosaic and 1 band
285 m_trackingCube->setDimensions(OutputCubes[0]->sampleCount(),
286 OutputCubes[0]->lineCount(),
287 1);
288
289 // The tracking cube file name convention is "output_cube_file_name" + "_tracking.cub"
290 QString trackingBase = FileName(OutputCubes[0]->fileName()).removeExtension().expanded().split("/").last();//toString();
291 m_trackingCube->create(FileName(OutputCubes[0]->fileName()).path()
292 + "/" + trackingBase + "_tracking.cub");
293
294 // Add the tracking group to the mosaic cube label
295 Pvl *mosaicLabel = OutputCubes[0]->label();
296 PvlGroup trackingFileGroup("Tracking");
297 PvlKeyword trackingFileName("FileName");
298 trackingFileName.setValue(trackingBase + "_tracking.cub");
299 trackingFileGroup.addKeyword(trackingFileName);
300 mosaicLabel->findObject("IsisCube").addGroup(trackingFileGroup);
301
302 // Write the bandbin group to the tracking cube label
303 Pvl *trackingLabel = m_trackingCube->label();
304 PvlGroup bandBin("BandBin");
305 PvlKeyword trackBand("FilterName");
306 trackBand += "TRACKING";
307 bandBin.addKeyword(trackBand);
308 trackingLabel->findObject("IsisCube").addGroup(bandBin);
309
310 // Write the mapping group to the tracking cube label
311 if (inLab->findObject("IsisCube").hasGroup("Mapping")) {
312 PvlGroup & mappingGroup = inLab->findGroup("Mapping", Pvl::Traverse);
313 trackingLabel->findObject("IsisCube").addGroup(mappingGroup);
314 }
315
316 // Initialize an empty TrackingTable object to manage tracking table in tracking cube
317 trackingTable = new TrackingTable();
318 }
319
320 // An existing mosaic cube is being added to
321 else {
322 // Confirm tracking group exists in mosaic cube to address backwards compatibility
323 if ( OutputCubes[0]->hasGroup("Tracking") ) {
324 QString trackingPath = FileName(OutputCubes[0]->fileName()).path();
325 QString trackingFile = OutputCubes[0]->group("Tracking").findKeyword("FileName")[0];
326 m_trackingCube->open(trackingPath + "/" + trackingFile, "rw");
327
328 // Initialize a TrackingTable object from current mosaic
329 Table *table;
330 try {
332 trackingTable = new TrackingTable(*table);
333 }
334 catch (IException &e) {
335 QString msg = "Unable to find Tracking Table in " + m_trackingCube->fileName() + ".";
336 throw IException(IException::User, msg, _FILEINFO_);
337 }
338 }
339 // If no tracking group exists in mosaic cube, warn user to run utility application to
340 // add it and create a separate tracking cube
341 else {
342 QString msg = "Tracking cannot be enabled when adding to an existing mosaic "
343 "that does not already have a tracking cube. Mosaics with a tracking band must "
344 "have the tracking band extracted into an external tracking cube.";
345 throw IException(IException::User, msg, _FILEINFO_);
346 }
347 }
348
349 // Add current file to the TrackingTable object
350 iIndex = trackingTable->fileNameToPixel(InputCubes[0]->fileName(),
352
353 // Write the tracking table to the tracking cube, overwriting if need-be
354 m_trackingCube->deleteBlob(Isis::trackingTableName, "Table");
355 Table table = trackingTable->toTable();
356 m_trackingCube->write(table);
357 }
358
359 }
360 else if (m_imageOverlay == AverageImageWithMosaic && m_createOutputMosaic) {
362 }
363
364 m_onb = OutputCubes[0]->bandCount();
365
366 if (m_trackingEnabled) {
367
368 // For mosaic creation, the input is copied onto mosaic by default
369 if (m_imageOverlay == UseBandPlacementCriteria && !m_createOutputMosaic) {
370 BandComparison(iss, isl, ins, inl,
371 bandPriorityInputBandNumber, bandPriorityOutputBandNumber, iIndex);
372 }
373 }
374 else if (m_imageOverlay == AverageImageWithMosaic) {
375 m_onb /= 2;
376 if (m_onb < 1) {
377 QString msg = "The mosaic cube needs a count band.";
378 throw IException(IException::Unknown, msg, _FILEINFO_);
379 }
380 }
381
382 // Process Band Priority with no tracking
383 if (m_imageOverlay == UseBandPlacementCriteria && !m_trackingEnabled ) {
384 BandPriorityWithNoTracking(iss, isl, isb, ins, inl, inb, bandPriorityInputBandNumber,
385 bandPriorityOutputBandNumber);
386 }
387 else {
388 // Create portal buffers for the input and output files
389 Portal iPortal(ins, 1, InputCubes[0]->pixelType());
390 Portal oPortal(ins, 1, OutputCubes[0]->pixelType());
391 Portal countPortal(ins, 1, OutputCubes[0]->pixelType());
392 Portal trackingPortal(ins, 1, PixelType::UnsignedInteger);
393
394 for (int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
395 for (int il = isl, ol = m_osl; il < isl + inl; il++, ol++) {
396 // Set the position of the portals in the input and output cubes
397 iPortal.SetPosition(iss, il, ib);
398 InputCubes[0]->read(iPortal);
399
400 oPortal.SetPosition(m_oss, ol, ob);
401 OutputCubes[0]->read(oPortal);
402
403 if (m_trackingEnabled) {
404 trackingPortal.SetPosition(m_oss, ol, 1);
405 m_trackingCube->read(trackingPortal);
406 }
407 else if (m_imageOverlay == AverageImageWithMosaic) {
408 countPortal.SetPosition(m_oss, ol, (ob+m_onb));
409 OutputCubes[0]->read(countPortal);
410 }
411
412 bool bChanged = false;
413 // Move the input data to the output
414 for (int pixel = 0; pixel < oPortal.size(); pixel++) {
415 // Creating Mosaic, copy the input onto mosaic
416 // regardless of the priority
417 if (m_createOutputMosaic) {
418 oPortal[pixel] = iPortal[pixel];
419 if (m_trackingEnabled) {
420 trackingPortal[pixel] = iIndex;
421 bChanged = true;
422 }
423 else if (m_imageOverlay == AverageImageWithMosaic) {
424 if (IsValidPixel(iPortal[pixel])) {
425 countPortal[pixel]=1;
426 bChanged = true;
427 }
428 }
429 }
430 // Band Priority
431 else if (m_trackingEnabled && m_imageOverlay == UseBandPlacementCriteria) {
432 int iPixelOrigin = qRound(trackingPortal[pixel]);
433
434 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
435 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
436 iComparePortal.SetPosition(iss, il, bandPriorityInputBandNumber);
437 InputCubes[0]->read(iComparePortal);
438 oComparePortal.SetPosition(m_oss, ol, bandPriorityOutputBandNumber);
439 OutputCubes[0]->read(oComparePortal);
440
441 if (iPixelOrigin == iIndex) {
442 if ( ( IsValidPixel(iComparePortal[pixel]) &&
443 IsValidPixel(oComparePortal[pixel]) ) &&
444 ( (!m_bandPriorityUseMaxValue &&
445 iComparePortal[pixel] < oComparePortal[pixel]) ||
446 (m_bandPriorityUseMaxValue &&
447 iComparePortal[pixel] > oComparePortal[pixel]) ) ) {
448
449 if ( IsValidPixel(iPortal[pixel]) ||
450 ( m_placeHighSatPixels && IsHighPixel(iPortal[pixel]) ) ||
451 ( m_placeLowSatPixels && IsLowPixel (iPortal[pixel]) ) ||
452 ( m_placeNullPixels && IsNullPixel(iPortal[pixel]) ) ){
453 oPortal[pixel] = iPortal[pixel];
454 bChanged = true;
455 }
456 }
457 else { //bad comparison
458 if ( ( IsValidPixel(iPortal[pixel]) && !IsValidPixel(oPortal[pixel]) ) ||
459 ( m_placeHighSatPixels && IsHighPixel(iPortal[pixel]) ) ||
460 ( m_placeLowSatPixels && IsLowPixel (iPortal[pixel]) ) ||
461 ( m_placeNullPixels && IsNullPixel(iPortal[pixel]) ) ) {
462 oPortal[pixel] = iPortal[pixel];
463 bChanged = true;
464 }
465 }
466 }
467 }
468 // OnTop/Input Priority
469 else if (m_imageOverlay == PlaceImagesOnTop) {
470 if (IsNullPixel(oPortal[pixel]) ||
471 IsValidPixel(iPortal[pixel]) ||
472 (m_placeHighSatPixels && IsHighPixel(iPortal[pixel])) ||
473 (m_placeLowSatPixels && IsLowPixel(iPortal[pixel])) ||
474 (m_placeNullPixels && IsNullPixel(iPortal[pixel]))) {
475 oPortal[pixel] = iPortal[pixel];
476 if (m_trackingEnabled) {
477 trackingPortal[pixel] = iIndex;
478 bChanged = true;
479 }
480 }
481 }
482 // AverageImageWithMosaic priority
483 else if (m_imageOverlay == AverageImageWithMosaic) {
484 bChanged |= ProcessAveragePriority(pixel, iPortal, oPortal, countPortal);
485 }
486 // Beneath/Mosaic Priority
487 else if (m_imageOverlay == PlaceImagesBeneath) {
488 if (IsNullPixel(oPortal[pixel])) {
489 oPortal[pixel] = iPortal[pixel];
490 // Set the origin if number of input bands equal to 1
491 // and if the track flag was set
492 if (m_trackingEnabled) {
493 trackingPortal[pixel] = iIndex;
494 bChanged = true;
495 }
496 }
497 }
498 } // End sample loop
499 if (bChanged) {
500 if (m_trackingEnabled) {
501 m_trackingCube->write(trackingPortal);
502 }
503 if (m_imageOverlay == AverageImageWithMosaic) {
504 OutputCubes[0]->write(countPortal);
505 }
506 }
507 OutputCubes[0]->write(oPortal);
509 } // End line loop
510 } // End band loop
511 }
512 if (m_trackingCube) {
514 delete m_trackingCube;
515 m_trackingCube = NULL;
516 }
517 } // End StartProcess
518
519
524 if (m_trackingCube) {
526 delete m_trackingCube;
527 m_trackingCube = NULL;
528 }
530 }
531
532
541
542
580 Cube *ProcessMosaic::SetInputCube(const QString &parameter,
581 const int ss, const int sl, const int sb,
582 const int ns, const int nl, const int nb) {
583
584 // Make sure only one input is active at a time
585 if (InputCubes.size() > 0) {
586 QString m = "You must specify exactly one input cube";
587 throw IException(IException::Programmer, m, _FILEINFO_);
588 }
589
590 m_iss = ss;
591 m_isl = sl;
592 m_isb = sb;
593 m_ins = ns;
594 m_inl = nl;
595 m_inb = nb;
596
597 Cube *cInCube = Process::SetInputCube(parameter);
598
599 //get the output label
600 Pvl *cInPvl = InputCubes[0]->label();
601 if (cInPvl->findGroup("Dimensions", Pvl::Traverse).hasKeyword("Bands")) {
602 PvlKeyword &cBandKey = cInPvl->findGroup("Dimensions", Pvl::Traverse).findKeyword("Bands");
603 QString sStr(cBandKey[0]);
604 if (toInt(sStr) < nb) {
605 QString m = "The parameter number of input bands exceeds the actual number of bands in the "
606 "input cube";
607 throw IException(IException::Programmer, m, _FILEINFO_);
608 }
609 }
610 return cInCube;
611 }
612
613
650 Cube *ProcessMosaic::SetInputCube(const QString &fname,
652 const int ss, const int sl, const int sb,
653 const int ns, const int nl, const int nb) {
654
655 // Make sure only one input is active at a time
656 if (InputCubes.size() > 0) {
657 QString m = "You must specify exactly one input cube";
658 throw IException(IException::Programmer, m, _FILEINFO_);
659 }
660
661 m_iss = ss;
662 m_isl = sl;
663 m_isb = sb;
664 m_ins = ns;
665 m_inl = nl;
666 m_inb = nb;
667
668 Cube *cInCube = Process::SetInputCube(fname, att);
669
670 //check if the number of bands specified is not greater than the actual number of bands in the input
671 Pvl *cInPvl = InputCubes[0]->label();
672 if (cInPvl->findGroup("Dimensions", Pvl::Traverse).hasKeyword("Bands")) {
673 PvlKeyword &cBandKey = cInPvl->findGroup("Dimensions", Pvl::Traverse).findKeyword("Bands");
674 QString sStr(cBandKey[0]);
675 if (toInt(sStr) < nb) {
676 QString m = "The parameter number of input bands exceeds the actual number of bands in the input cube";
677 throw IException(IException::Programmer, m, _FILEINFO_);
678 }
679 }
680 return cInCube;
681 }
682
683
698 Cube *ProcessMosaic::SetOutputCube(const QString &psParameter) {
699 return SetOutputCube(psParameter, Application::GetUserInterface());
700 }
701
702
703 Cube *ProcessMosaic::SetOutputCube(const QString &psParameter, UserInterface &ui) {
704 QString fname = ui.GetCubeName(psParameter);
705
706 // Make sure there is only one output cube
707 if (OutputCubes.size() > 0) {
708 QString m = "You must specify exactly one output cube";
709 throw IException(IException::Programmer, m, _FILEINFO_);
710 }
711
712 // Attempt to open a cube ... get the filename from the user parameter
713 // (e.g., "TO") and the cube size from an input cube
714 Cube *cube = new Cube;
715 try {
716 cube->open(fname, "rw");
717 }
718 catch (IException &) {
719 delete cube;
720 throw;
721 }
722
723 if (m_createOutputMosaic) {
724 Pvl *outLab = cube->label();
725 if (outLab->findObject("IsisCube").hasGroup("BandBin")) {
726 outLab->findObject("IsisCube").deleteGroup("BandBin");
727 }
728 }
729
730 // Everything is fine so save the cube on the stack
731 AddOutputCube(cube);
732 return cube;
733 }
734
735
739 void ProcessMosaic::SetBandBinMatch(bool enforceBandBinMatch) {
740 m_enforceBandBinMatch = enforceBandBinMatch;
741 }
742
743
747 void ProcessMosaic::SetBandKeyword(QString bandPriorityKeyName, QString bandPriorityKeyValue) {
748 m_bandPriorityKeyName = bandPriorityKeyName;
749 m_bandPriorityKeyValue = bandPriorityKeyValue;
750 }
751
752
756 void ProcessMosaic::SetBandNumber(int bandPriorityBandNumber) {
757 m_bandPriorityBandNumber = bandPriorityBandNumber;
758 }
759
760
766 m_bandPriorityUseMaxValue = useMax;
767 }
768
769
778 void ProcessMosaic::SetCreateFlag(bool createOutputMosaic) {
779 m_createOutputMosaic = createOutputMosaic;
780 }
781
782
787 void ProcessMosaic::SetHighSaturationFlag(bool placeHighSatPixels) {
788 m_placeHighSatPixels = placeHighSatPixels;
789 }
790
791
792 void ProcessMosaic::SetImageOverlay(ImageOverlay placement) {
793 m_imageOverlay = placement;
794 }
795
796
801 void ProcessMosaic::SetLowSaturationFlag(bool placeLowSatPixels) {
802 m_placeLowSatPixels = placeLowSatPixels;
803 }
804
809 void ProcessMosaic::SetMatchDEM(bool matchDEM) {
810 m_enforceMatchDEM = matchDEM;
811 }
812
813
818 void ProcessMosaic::SetNullFlag(bool placeNullPixels) {
819 m_placeNullPixels = placeNullPixels;
820 }
821
822
823 void ProcessMosaic::SetTrackFlag(bool trackingEnabled) {
824 m_trackingEnabled = trackingEnabled;
825 }
826
827
832 return m_placeHighSatPixels;
833 }
834
835
839 ProcessMosaic::ImageOverlay ProcessMosaic::GetImageOverlay() const {
840 return m_imageOverlay;
841 }
842
843
848 return m_placeLowSatPixels;
849 }
850
851
856 return m_placeNullPixels;
857 }
858
859
864 return m_trackingEnabled;
865 }
866
867
872 return m_osl;
873 }
874
875
880 return m_oss;
881 }
882
883
888 return m_osb;
889 }
890
891
897 QString result;
898
899 switch (imageOverlay) {
900 case PlaceImagesOnTop:
901 result = "OnTop";
902 break;
903
905 result = "Beneath";
906 break;
907
909 result = "Band";
910 break;
911
913 result = "Average";
914 break;
915
916 case NumImageOverlayOptions:
917 break;
918 }
919
920 if (result == "") {
922 "Cannot convert overlay [" + toString((int)imageOverlay) + "] to a string",
923 _FILEINFO_);
924 }
925
926 return result;
927 }
928
929
935 QString imageOverlayStringUpper = imageOverlayString.toUpper();
936 for (int i = 0; i < NumImageOverlayOptions; i++) {
937 if (OverlayToString((ImageOverlay)i).toUpper() == imageOverlayStringUpper)
938 return (ImageOverlay)i;
939 }
940
942 "The text [" + imageOverlayString + "] does not correspond to any known "
943 "image overlay modes (mosaic priorities)",
944 _FILEINFO_);
945 }
946
947
956 Pvl* inLabel = InputCubes[0]->label();
957 Pvl* outLabel = OutputCubes[0]->label();
958
959 if (outLabel->findObject("IsisCube").hasGroup("Mosaic")) {
960 PvlGroup outMosaicGrp = outLabel->findObject("IsisCube").findGroup("Mosaic");
961 if (outMosaicGrp.hasKeyword("ShapeModel")) {
962 if (inLabel->findObject("IsisCube").hasGroup("Kernels")) {
963 PvlGroup inMosaicGrp = inLabel->findObject("IsisCube").findGroup("Kernels");
964 if (outMosaicGrp.hasKeyword("ShapeModel") && inMosaicGrp.hasKeyword("ShapeModel")) {
965 PvlKeyword outShapeModelKey = outMosaicGrp.findKeyword("ShapeModel");
966 QString sShapeModel = inMosaicGrp.findKeyword("ShapeModel")[0];
967 int found = sShapeModel.lastIndexOf("/");
968 if (found != -1) {
969 sShapeModel.remove(0, found + 1);
970 }
971 if (sShapeModel == outShapeModelKey[0]) {
972 return;
973 }
974 }
975 }
976 QString sErrMsg = "Input and Mosaic DEM Shape Model do not match";
977 throw IException(IException::User, sErrMsg, _FILEINFO_);
978 }
979 }
980 else {
981 if (m_createOutputMosaic) {
982 if (inLabel->findObject("IsisCube").hasGroup("Kernels")) {
983 QString sShapeModel =
984 inLabel->findObject("IsisCube").findGroup("Kernels").findKeyword("ShapeModel")[0];
985 int found = sShapeModel.lastIndexOf("/");
986 if (found != -1){
987 sShapeModel.remove(0, found+1);
988 }
989 PvlObject & outIsisCubeObj = outLabel->findObject("IsisCube");
990 PvlGroup mosaicGrp("Mosaic");
991 PvlKeyword shapeModelKey("ShapeModel");
992 shapeModelKey += sShapeModel;
993 mosaicGrp += shapeModelKey;
994 outIsisCubeObj += mosaicGrp;
995 }
996 }
997 }
998 }
999
1000
1007 {
1008 int iBand = OutputCubes[0]->bandCount();
1009 int iLines = OutputCubes[0]->lineCount();
1010 int iSample = OutputCubes[0]->sampleCount();
1011
1012 Portal countPortal(iSample, 1, OutputCubes[0]->pixelType());
1013 int iStartCountBand = iBand/2 + 1;
1014
1015 for (int band=iStartCountBand; band<=iBand; band++) {
1016 for (int i = 1; i <= iLines; i++) {
1017 countPortal.SetPosition(1, i, band); //sample, line, band position
1018 OutputCubes[0]->read(countPortal);
1019 for (int iPixel = 0; iPixel < countPortal.size(); iPixel++) {
1020 countPortal[iPixel] = 0;
1021 }
1022 OutputCubes[0]->write(countPortal);
1023 }
1024 }
1025 }
1026
1027
1041 bool ProcessMosaic::ProcessAveragePriority(int piPixel, Portal& piPortal, Portal& poPortal,
1042 Portal& countPortal)
1043 {
1044 bool bChanged=false;
1045 if (IsValidPixel(piPortal[piPixel]) && IsValidPixel(poPortal[piPixel])) {
1046 int iCount = (int)countPortal[piPixel];
1047 double dNewDN = (poPortal[piPixel] * iCount + piPortal[piPixel]) / (iCount + 1);
1048 poPortal[piPixel] = dNewDN;
1049 countPortal[piPixel] =iCount +1;
1050 bChanged = true;
1051 }
1052 // Input-Valid, Mosaic-Special
1053 else if (IsValidPixel(piPortal[piPixel])) {
1054 poPortal[piPixel] = piPortal[piPixel];
1055 countPortal[piPixel] = 1;
1056 bChanged = true;
1057 }
1058 // Input-Special, Flags-True
1059 else if (IsSpecial(piPortal[piPixel])) {
1060 if ((m_placeHighSatPixels && IsHighPixel(piPortal[piPixel])) ||
1061 (m_placeLowSatPixels && IsLowPixel (piPortal[piPixel])) ||
1062 (m_placeNullPixels && IsNullPixel(piPortal[piPixel]))) {
1063 poPortal[piPixel] = piPortal[piPixel];
1064 countPortal[piPixel] = 0;
1065 bChanged = true;
1066 }
1067 }
1068 return bChanged;
1069 }
1070
1071
1083 void ProcessMosaic::MatchBandBinGroup(int origIsb, int &inb) {
1084 Pvl *inLab = InputCubes[0]->label();
1085 Pvl *outLab = OutputCubes[0]->label();
1086
1087 PvlGroup &inBin = inLab->findGroup("BandBin", Pvl::Traverse);
1088 PvlGroup &outBin = outLab->findGroup("BandBin", Pvl::Traverse);
1089 if (inBin.keywords() != outBin.keywords()) {
1090 QString msg = "Pvl Group [BandBin] does not match between the input and output cubes";
1091 throw IException(IException::User, msg, _FILEINFO_);
1092 }
1093
1094 //pvl - zero based
1095 int isb = (origIsb - 1);
1096 int osb = (m_osb - 1);
1097 int iOutBandsHalf = OutputCubes[0]->bandCount()/2;
1098
1099 for (int i = 0; i < outBin.keywords(); i++) {
1100 PvlKeyword &outKey = outBin[i];
1101 QString sOutName = outKey.name();
1102 if (inBin.hasKeyword(sOutName)) {
1103 PvlKeyword &inKey = inBin[sOutName];
1104 for (int j = osb, k = isb; j < outKey.size() && k < inKey.size(); j++, k++) {
1105 if (outKey[j] == "NA") {
1106 outKey[j] = inKey[k];
1107 if (m_imageOverlay == AverageImageWithMosaic) {
1108 if (sOutName.contains("Filter") ||
1109 sOutName.contains("Name")) {
1110 outKey[j+iOutBandsHalf] = inKey[k] + "_Count";
1111 }
1112 else {
1113 outKey[j+iOutBandsHalf] = "Avg_Count";
1114 }
1115 }
1116 }
1117 else if (outKey[j] != inKey[k]) {
1118 QString msg = "The input cube [" + inLab->fileName() + "] and the base mosaic values "
1119 "of the Pvl Group [BandBin] for Keyword [" + outKey.name() + "] do not "
1120 "match. Base mosaic value at index [" + QString::number(j) + "] = " +
1121 outKey[j] + ". Input cube value at index [" + QString::number(k) + "] = "
1122 + inKey[k] + ". **Note: use mapmos/automos MatchBandBin = false to "
1123 "override this check**";
1124 //QString msg = "Pvl Group [BandBin] in Key[" + outKey.name() + "] In value" + inKey[k] +
1125 //"and Out value=" + outKey[j] + " do not match";
1126 throw IException(IException::User, msg, _FILEINFO_);
1127 }
1128 }
1129 }
1130 else {
1131 QString msg = "Pvl Group [BandBin] In Keyword[" + inBin[i].name() + "] and Out Keyword[" +
1132 outBin[i].name() + "] does not match";
1133 throw IException(IException::User, msg, _FILEINFO_);
1134 }
1135 }
1136
1137 int inputRange = InputCubes[0]->bandCount() - isb;
1138 int outputRange = OutputCubes[0]->bandCount() - osb;
1139 inb = min(inputRange, outputRange);
1140 }
1141
1142
1155 Pvl *inLab = InputCubes[0]->label();
1156 Pvl *outLab = OutputCubes[0]->label();
1157
1158 int iOutBands = OutputCubes[0]->bandCount();
1159
1160 // else if (m_imageOverlay == AverageImageWithMosaic) {
1161 if (m_imageOverlay == AverageImageWithMosaic) {
1162 iOutBands /= 2;
1163 }
1164
1165 int isb = origIsb - 1; // array zero based
1166 int osb = m_osb - 1;
1167
1168 PvlGroup &cInBin = inLab->findGroup("BandBin", Pvl::Traverse);
1169 PvlGroup cOutBin("BandBin");
1170
1171 for (int i = 0; i < cInBin.keywords(); i++) {
1172 PvlKeyword &cInKey = cInBin[i];
1173 int iInKeySize = cInKey.size();
1174 PvlKeyword cOutKey(cInKey.name());
1175
1176 for (int b = 0; b < osb; b++) {
1177 cOutKey += "NA";
1178 }
1179 for (int b = osb; b < iOutBands; b++) {
1180 if (isb < iInKeySize) {
1181 cOutKey += cInKey[isb++];
1182 }
1183 else {
1184 cOutKey += "NA";
1185 }
1186 }
1187
1188 // Tag the Count Bands if priority is AverageImageWithMosaic.
1189 if (m_imageOverlay == AverageImageWithMosaic) {
1190
1191 int iTotalOutBands = OutputCubes[0]->bandCount();
1192 isb = origIsb - 1; // reset the input starting band
1193 int iOutStartBand = iOutBands + osb;
1194 QString sKeyName = cInKey.name();
1195 bool bFilterKey = false;
1196 if (sKeyName.contains("Filter") ||
1197 sKeyName.contains("Original") ||
1198 sKeyName.contains("Name")) {
1199 bFilterKey = true;
1200 }
1201 for (int ob=iOutBands; ob<iTotalOutBands; ob++) {
1202 if (isb < iInKeySize && ob >= iOutStartBand) {
1203 if (bFilterKey) {
1204 cOutKey += cInKey[isb++] + "_Count";
1205 }
1206 else {
1207 cOutKey += 0;
1208 isb++;
1209 }
1210 }
1211 else {
1212 cOutKey += 0;
1213 }
1214 }
1215 }
1216
1217 // Check for units and make sure output keyword units value is set to input
1218 // keyword units value
1219 if (cOutKey.unit() != cInKey.unit()) {
1220 cOutKey.setUnits((QString)(cInKey.unit()));
1221 }
1222
1223 cOutBin += cOutKey;
1224 isb = origIsb - 1; // reinitialize the input starting band
1225 }
1226 outLab->findObject("IsisCube").addGroup(cOutBin);
1227 }
1228
1229
1240 Pvl *outLab = OutputCubes[0]->label();
1241
1242 PvlGroup cOutBin("BandBin");
1243
1244 int iOutBands = OutputCubes[0]->bandCount();
1245 int iOutBandsTotal = iOutBands;
1246
1247 if (m_trackingEnabled) {
1248 iOutBands--; // Leave tracking band
1249 }
1250 else if (m_imageOverlay == AverageImageWithMosaic) {
1251 iOutBands /= 2;
1252 }
1253
1254 PvlKeyword cOutKey("FilterName");
1255
1256 for (int i=0; i<iOutBands; i++) {
1257 cOutKey += "NA";
1258 }
1259
1260 if (m_imageOverlay == AverageImageWithMosaic) {
1261 for (int i=iOutBands; i<iOutBandsTotal; i++) {
1262 cOutKey += "NA_Count";
1263 }
1264 }
1265
1266 if (m_trackingEnabled) {
1267 cOutKey += "TRACKING";
1268 }
1269
1270 cOutBin += cOutKey;
1271
1272 outLab->findObject("IsisCube").addGroup(cOutBin);
1273 }
1274
1275
1279 int ProcessMosaic::GetBandIndex(bool inputFile) {
1280 bool bFound = false;
1281 int iBandIndex = 0;
1282
1283 Pvl cPvlLabel;
1284
1285 if (inputFile) {
1286 cPvlLabel = *(InputCubes[0]->label());
1287 if (m_bandPriorityBandNumber <= InputCubes[0]->bandCount() &&
1288 m_bandPriorityBandNumber > 0) {
1289 iBandIndex = m_bandPriorityBandNumber;
1290 bFound = true;
1291 }
1292 }
1293 else {
1294 cPvlLabel = *(OutputCubes[0]->label());
1295 if (m_bandPriorityBandNumber <= OutputCubes[0]->bandCount() &&
1296 m_bandPriorityBandNumber > 0) {
1297 iBandIndex = m_bandPriorityBandNumber;
1298 bFound = true;
1299 }
1300 }
1301
1302 //key name
1303 if (!m_bandPriorityBandNumber) {
1304 PvlKeyword cKeyName;
1305 if (cPvlLabel.findGroup("BandBin", Pvl::Traverse).hasKeyword(m_bandPriorityKeyName)) {
1306 cKeyName = cPvlLabel.findGroup("BandBin", Pvl::Traverse).findKeyword(m_bandPriorityKeyName);
1307 }
1308 int iSize = cKeyName.size();
1309 for (int i = 0; i < iSize; i++) {
1310 if (m_bandPriorityKeyValue.toUpper() == cKeyName[i].toUpper()) {
1311 iBandIndex = i + 1; //1 based get key value index
1312 bFound = true;
1313 break;
1314 }
1315 }
1316 }
1317 if (!bFound) {
1318 QString msg = "Invalid Band / Key Name, Value ";
1319 throw IException(IException::User, msg, _FILEINFO_);
1320 }
1321 return iBandIndex;
1322 }
1323
1324
1342 void ProcessMosaic::BandComparison(int iss, int isl, int ins, int inl,
1343 int bandPriorityInputBandNumber, int bandPriorityOutputBandNumber, int index) {
1344 //
1345 // Create portal buffers for the input and output files
1346 Portal cIportal(ins, 1, InputCubes[0]->pixelType());
1347 Portal cOportal(ins, 1, OutputCubes[0]->pixelType());
1348 Portal trackingPortal(ins, 1, PixelType::UnsignedInteger);
1349
1350 for (int iIL = isl, iOL = m_osl; iIL < isl + inl; iIL++, iOL++) {
1351 // Set the position of the portals in the input and output cubes
1352 cIportal.SetPosition(iss, iIL, bandPriorityInputBandNumber);
1353 InputCubes[0]->read(cIportal);
1354
1355 cOportal.SetPosition(m_oss, iOL, bandPriorityOutputBandNumber);
1356 OutputCubes[0]->read(cOportal);
1357
1358 trackingPortal.SetPosition(m_oss, iOL, 1);
1359 m_trackingCube->read(trackingPortal);
1360
1361 // Move the input data to the output
1362 for (int iPixel = 0; iPixel < cOportal.size(); iPixel++) {
1363 if ((m_placeHighSatPixels && IsHighPixel(cIportal[iPixel])) ||
1364 (m_placeLowSatPixels && IsLowPixel(cIportal[iPixel])) ||
1365 (m_placeNullPixels && IsNullPixel(cIportal[iPixel]))) {
1366 trackingPortal[iPixel] = index;
1367 }
1368 else {
1369 if (IsValidPixel(cIportal[iPixel])) {
1370 if (IsSpecial(cOportal[iPixel]) ||
1371 (m_bandPriorityUseMaxValue == false && cIportal[iPixel] < cOportal[iPixel]) ||
1372 (m_bandPriorityUseMaxValue == true && cIportal[iPixel] > cOportal[iPixel])) {
1373 trackingPortal[iPixel] = index;
1374 }
1375 }
1376 }
1377 }
1378 m_trackingCube->write(trackingPortal);
1379 }
1380 }
1381
1382
1388void ProcessMosaic::BandPriorityWithNoTracking(int iss, int isl, int isb, int ins, int inl,
1389 int inb, int bandPriorityInputBandNumber,
1390 int bandPriorityOutputBandNumber) {
1391 /*
1392 * specified band for comparison
1393 * Create portal buffers for the input and output files pointing to the
1394 */
1395 Portal iComparePortal( ins, 1, InputCubes[0]->pixelType() );
1396 Portal oComparePortal( ins, 1, OutputCubes[0]->pixelType() );
1397 Portal resultsPortal ( ins, 1, OutputCubes[0]->pixelType() );
1398
1399 // Create portal buffers for the input and output files
1400 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1401 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1402
1403 for (int inLine = isl, outLine = m_osl; inLine < isl + inl; inLine++, outLine++) {
1404// Set the position of the portals in the input and output cubes
1405 iComparePortal.SetPosition(iss, inLine, bandPriorityInputBandNumber);
1406 InputCubes[0]->read(iComparePortal);
1407
1408 oComparePortal.SetPosition(m_oss, outLine, bandPriorityOutputBandNumber);
1409 OutputCubes[0]->read(oComparePortal);
1410
1411 Portal iPortal( ins, 1, InputCubes[0]->pixelType() );
1412 Portal oPortal( ins, 1, OutputCubes[0]->pixelType() );
1413
1414 bool inCopy = false;
1415// Move the input data to the output
1416 for (int iPixel = 0; iPixel < ins; iPixel++) {
1417 resultsPortal[iPixel] = false;
1418 if (m_createOutputMosaic) {
1419 resultsPortal[iPixel] = true;
1420 inCopy = true;
1421 }
1422 else if ( IsValidPixel(iComparePortal[iPixel]) && IsValidPixel(oComparePortal[iPixel]) ) {
1423 if ( (m_bandPriorityUseMaxValue == false &&
1424 iComparePortal[iPixel] < oComparePortal[iPixel]) ||
1425 (m_bandPriorityUseMaxValue == true &&
1426 iComparePortal[iPixel] > oComparePortal[iPixel]) ) {
1427 resultsPortal[iPixel] = true;
1428 inCopy = true;
1429 }
1430 }
1431 else if (IsValidPixel(iComparePortal[iPixel]) && !IsValidPixel(oComparePortal[iPixel]) ) {
1432 resultsPortal[iPixel] = true;
1433 inCopy = true;
1434 }
1435 }
1436 if (inCopy) {
1437 for (int ib = isb, ob = m_osb; ib < (isb + inb) && ob <= m_onb; ib++, ob++) {
1438// Set the position of the portals in the input and output cubes
1439 iPortal.SetPosition(iss, inLine, ib);
1440 InputCubes[0]->read(iPortal);
1441
1442 oPortal.SetPosition(m_oss, outLine, ob);
1443 OutputCubes[0]->read(oPortal);
1444
1445 for (int iPixel = 0; iPixel < ins; iPixel++) {
1446 if (resultsPortal[iPixel]) {
1447 if (m_createOutputMosaic) {
1448 oPortal[iPixel] = iPortal[iPixel];
1449 }
1450 else if ( IsValidPixel(iPortal[iPixel]) ||
1451 (m_placeHighSatPixels && IsHighPixel(iPortal[iPixel]) ) ||
1452 (m_placeLowSatPixels && IsLowPixel (iPortal[iPixel]) ) ||
1453 (m_placeNullPixels && IsNullPixel(iPortal[iPixel]) ) ) {
1454 oPortal[iPixel] = iPortal[iPixel];
1455 }
1456 }
1457 else if ( IsValidPixel(iPortal[iPixel]) && !IsValidPixel(oPortal[iPixel]) ) {
1458 oPortal[iPixel] = iPortal[iPixel];
1459 }
1460 }
1461 OutputCubes[0]->write(oPortal);
1462 }
1463 }
1464 }
1465 }
1466
1467
1481 int iDefault;
1482
1483 switch (SizeOf(OutputCubes[0]->pixelType())) {
1484 case 1:
1485 iDefault = NULL1;
1486 break;
1487
1488 case 2:
1489 iDefault = NULL2;
1490 break;
1491
1492 case 4:
1493 iDefault = INULL4;
1494 break;
1495
1496 default:
1497 QString msg = "ProcessMosaic::GetOriginDefaultByPixelType - Invalid Pixel Type";
1498 throw IException(IException::Programmer, msg, _FILEINFO_);
1499 }
1500
1501 return iDefault;
1502 }
1503
1504
1515 //get the output label
1516 Pvl *cPvlOut = OutputCubes[0]->label();
1517
1518 bool bGroupExists = false;
1519 PvlObject cPvlObj;
1520
1521 //Check if table already exists
1522 if (cPvlOut->hasGroup("Tracking")) {
1523 bGroupExists = true;
1524 }
1525
1526 return bGroupExists;
1527 }
1528
1529}
static UserInterface & GetUserInterface()
Returns the UserInterface object.
Manipulate and parse attributes of input cube filenames.
IO Handler for Isis Cubes.
Definition Cube.h:168
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Definition Cube.cpp:1310
bool deleteBlob(QString BlobName, QString BlobType)
This method will delete a blob label object from the cube as specified by the Blob type and name.
Definition Cube.cpp:1961
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Definition Cube.cpp:1223
void create(const QString &cfile)
This method will create an isis cube for writing.
Definition Cube.cpp:409
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
Definition Cube.cpp:622
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition Cube.cpp:813
virtual QString fileName() const
Returns the opened cube's filename.
Definition Cube.cpp:1569
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
Definition Cube.cpp:977
void close(bool remove=false)
Closes the cube and updates the labels.
Definition Cube.cpp:255
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
File name manipulation and expansion.
Definition FileName.h:100
QString path() const
Returns the path of the file name.
Definition FileName.cpp:103
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
FileName removeExtension() const
Removes all extensions in the file name.
Definition FileName.cpp:246
Isis exception class.
Definition IException.h:91
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
Buffer for containing a two dimensional section of an image.
Definition Portal.h:36
virtual void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
Definition Process.cpp:462
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Definition Process.h:185
Isis::Progress * p_progress
Pointer to a Progress object.
Definition Process.h:145
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
Definition Process.h:191
virtual Isis::Cube * SetInputCube(const QString &parameter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
Definition Process.cpp:139
void SetMatchDEM(bool matchDEM)
Set the DEM match flag.
void BandPriorityWithNoTracking(int iss, int isl, int isb, int ins, int inl, int inb, int bandPriorityInputBandNumber, int bandPriorityOutputBandNumber)
Mosaicking for Band Priority with no Tracking.
virtual void StartProcess(const int &piOutSample, const int &piOutLine, const int &piOutBand)
This method invokes the process by mosaic operation over a single input cube and single output cube.
bool m_enforceMatchDEM
DEM of the input and mosaic should match.
void BandComparison(int iss, int isl, int ins, int inl, int bandPriorityInputBandNumber, int bandPriorityOutputBandNumber, int index)
This method compares the specified band of the input and output using the criteria (lesser or greater...
bool GetLowSaturationFlag() const
int m_onb
The number of bands in the output cube.
int m_isl
The starting line within the input cube.
Isis::Cube * SetOutputCube(const QString &psParameter)
Opens an output cube specified by the user.
ImageOverlay
Enumeration for different Mosaic priorities (input, mosaic, band)
@ PlaceImagesOnTop
ontop priority
@ UseBandPlacementCriteria
band priority
@ PlaceImagesBeneath
beneath priority
@ AverageImageWithMosaic
average priority
bool GetTrackFlag() const
int m_oss
The starting sample within the output cube.
virtual ~ProcessMosaic()
Destroys the Mosaic object. It will close all opened cubes.
bool GetHighSaturationFlag() const
int GetInputStartLineInMosaic() const
This is the line where the image was placed into the output mosaic.
void SetLowSaturationFlag(bool placeLowSatPixels)
When true, low saturation (LRS, LIS) will be considered valid data for the purposes of placing pixels...
int m_isb
The starting band within the input cube.
virtual void EndProcess()
Cleans up by closing input, output and tracking cubes.
int m_iss
The starting sample within the input cube.
void SetHighSaturationFlag(bool placeHighSatPixels)
When true, high saturation (HRS, HIS) will be considered valid data for the purposes of placing pixel...
static ImageOverlay StringToOverlay(QString)
Convert a QString to an ImageOverlay (case-insensitive).
PvlObject imagePositions()
Accessor for the placed images and their locations.
int m_ins
The number of samples from the input cube.
Cube * m_trackingCube
Output tracking cube. NULL unless tracking is enabled.
void SetCreateFlag(bool createOutputMosaic)
Flag to indicate that the mosaic is being newly created Indication that the new label specific to the...
int m_inl
The number of lines from the input cube.
static QString OverlayToString(ImageOverlay)
Convert an ImageOverlay to a QString.
void SetBandNumber(int bandPriorityBandNumber)
Set the band to use for priorities when using band priority.
int GetInputStartBandInMosaic() const
This is the band where the image was placed into the output mosaic.
bool GetTrackStatus()
This method searchs the mosaic label for a table with name "InputFile".
int m_inb
The number of bands from the input cube.
void SetBandKeyword(QString bandPriorityKeyName, QString bandPriorityKeyValue)
Set the keyword/value to use for comparing when using band priority.
bool ProcessAveragePriority(int piPixel, Portal &pInPortal, Portal &pOutPortal, Portal &pOrigPortal)
Calculate DN value for a pixel for AverageImageWithMosaic priority and set the Count band portal.
void AddDefaultBandBinGroup()
AddDefaultBandBinGroup.
static const char * TRACKING_TABLE_NAME
This is the name of the table in the Cube which will contain the image file names.
int m_osb
The starting band within the output cube.
ProcessMosaic()
ProcessMosaic Contructor.
void MatchBandBinGroup(int origIsb, int &inb)
This method matches the input BandBin group to the mosaic BandBin Group and allows band to be replace...
virtual Isis::Cube * SetInputCube(const QString &parameter, const int ss, const int sl, const int sb, const int ns, const int nl, const int nb)
Opens an input cube specified by the user.
int GetBandIndex(bool inputFile)
Get the Band Index in an image of type (input/output)
void SetBandUseMaxValue(bool useMax)
Set whether to take the image with the max or min value when using band priority.
void SetNullFlag(bool placeNullPixels)
When true, Null pixels will be considered valid data for the purposes of placing pixels in the output...
int GetOriginDefaultByPixelType()
This method returns the defaults(unassigned origin value) depending on the pixel type.
int GetInputStartSampleInMosaic() const
This is the sample where the image was placed into the output mosaic.
void ResetCountBands()
Reset all the count bands to default at the time of mosaic creation.
void AddBandBinGroup(int origIsb)
This method adds the BandBin group to the mosaic corresponding to the actual bands in the mosaic.
bool m_enforceBandBinMatch
True/False value to determine whether to enforce the input cube bandbin matches the mosaic bandbin gr...
PvlObject m_imagePositions
List of images placed on the mosaic.
int m_osl
The starting line within the output cube.
void MatchDEMShapeModel()
Match the Shape Model for input and mosaic.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
Definition Progress.cpp:85
void CheckStatus()
Checks and updates the status.
Definition Progress.cpp:105
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
QString name() const
Returns the keyword name.
Definition PvlKeyword.h:103
int size() const
Returns the number of values stored in this keyword.
Definition PvlKeyword.h:133
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition PvlObject.h:276
@ Traverse
Search child objects.
Definition PvlObject.h:158
static QString Compose(Pvl &label, bool def2filename=false)
Compose a SerialNumber from a PVL.
Class for storing Table blobs information.
Definition Table.h:61
Table to store tracking information for a mosaic.
Command Line and Xml loader, validation, and access.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int SizeOf(Isis::PixelType pixelType)
Returns the number of bytes of the specified PixelType.
Definition PixelType.h:46
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
bool IsNullPixel(const double d)
Returns if the input pixel is null.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
bool IsSpecial(const double d)
Returns if the input pixel is special.
bool IsHighPixel(const double d)
Returns if the input pixel is one of the high saturation types.
bool IsLowPixel(const double d)
Returns if the input pixel is one of the low saturation types.
Namespace for the standard library.