|
Isis 3.0 Application Source Code Reference |
Home |
00001 #include "Isis.h" 00002 #include "ProcessMosaic.h" 00003 #include "ProcessByLine.h" 00004 #include "SpecialPixel.h" 00005 00006 using namespace std; 00007 using namespace Isis; 00008 00009 void CreateMosaic(Buffer &buf); 00010 00011 /** 00012 * Handmos Application- Allows to hand place an image on the 00013 * mosaic with input, mosaic and band priorities. Band priority allows the 00014 * user the option to place a pixel on the mosaic based on the pixel in the 00015 * chosen band. The band can be specified by band number or Keyword as it 00016 * appears in BandBin group of the PVL label. Also has the ability to track the 00017 * origin by adding a band to mosaic at the time of creation. As input images 00018 * are placed on the mosaic, the are stored as records in the table "InputImages" 00019 * in the mosaic. Ability to copy HS, LS, NULL values from input onto the mosaic. 00020 * 00021 */ 00022 void IsisMain() { 00023 // See if we need to create the output file 00024 UserInterface &ui = Application::GetUserInterface(); 00025 00026 int ns, nl, nb; 00027 00028 ProcessMosaic p; 00029 00030 bool bTrack = ui.GetBoolean("TRACK"); 00031 p.SetTrackFlag(bTrack); 00032 00033 QString inputFile = ui.GetAsString("FROM"); 00034 QString mosaicFile = ui.GetFileName("MOSAIC"); 00035 00036 // Set up the mosaic priority, either the input cube will be 00037 // placed ontop of the mosaic or beneath it 00038 ProcessMosaic::ImageOverlay overlay = ProcessMosaic::StringToOverlay( 00039 ui.GetString("PRIORITY")); 00040 QString sType; 00041 00042 if (overlay == ProcessMosaic::UseBandPlacementCriteria) { 00043 if (ui.GetString("TYPE") == "BANDNUMBER") { 00044 p.SetBandNumber(ui.GetInteger("NUMBER")); 00045 } 00046 else { 00047 // Key name & value 00048 p.SetBandKeyword(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); 00049 } 00050 // Band Criteria 00051 p.SetBandUseMaxValue( (ui.GetString("CRITERIA") == "GREATER") ); 00052 } 00053 00054 // Priority 00055 p.SetImageOverlay(overlay); 00056 00057 if (ui.GetString("CREATE") == "YES") { 00058 ns = ui.GetInteger("NSAMPLES"); 00059 nl = ui.GetInteger("NLINES"); 00060 nb = ui.GetInteger("NBANDS"); 00061 00062 // Create the origin band if the Track Flag is set 00063 if (bTrack) { 00064 nb += 1; 00065 } 00066 else if (overlay == ProcessMosaic::AverageImageWithMosaic) { 00067 nb *= 2; 00068 } 00069 p.SetCreateFlag(true); 00070 00071 ProcessByLine bl; 00072 00073 bl.Progress()->SetText("Initializing base mosaic"); 00074 CubeAttributeInput iAtt(inputFile); 00075 bl.SetInputCube(inputFile, iAtt); 00076 00077 if (!ui.GetBoolean("Propagate")) { 00078 bl.PropagateHistory(false); 00079 bl.PropagateLabels(false); 00080 bl.PropagateTables(false); 00081 bl.PropagatePolygons(false); 00082 bl.PropagateOriginalLabel(false); 00083 } 00084 00085 CubeAttributeOutput oAtt = ui.GetOutputAttribute("MOSAIC"); 00086 bl.SetOutputCube(mosaicFile, oAtt, ns, nl, nb); 00087 bl.ClearInputCubes(); 00088 00089 // Initialize the mosaic to defaults 00090 bl.StartProcess(CreateMosaic); 00091 bl.EndProcess(); 00092 } 00093 00094 // Set the input cube for the process object 00095 p.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN")); 00096 p.Progress()->SetText("Mosaicking"); 00097 00098 // Get the MatchDEM Flag 00099 p.SetMatchDEM(ui.GetBoolean("MATCHDEM")); 00100 00101 // Get the value for HS, LS, NULL flags whether to transfer the special pixels 00102 // onto the mosaic. Holds good for "ontop" and "band" priorities only 00103 if (overlay != ProcessMosaic::PlaceImagesBeneath) { 00104 p.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); 00105 p.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION")); 00106 p.SetNullFlag(ui.GetBoolean("NULL")); 00107 } 00108 00109 // Get the starting line/sample/band to place the input cube 00110 int outSample = ui.GetInteger("OUTSAMPLE") - ui.GetInteger("INSAMPLE") + 1; 00111 int outLine = ui.GetInteger("OUTLINE") - ui.GetInteger("INLINE") + 1; 00112 int outBand = ui.GetInteger("OUTBAND") - ui.GetInteger("INBAND") + 1; 00113 00114 // Set the input image and attributes 00115 CubeAttributeInput inAtt(inputFile); 00116 p.SetInputCube(inputFile, inAtt); 00117 00118 // Set the output mosaic 00119 Cube *to = p.SetOutputCube("MOSAIC"); 00120 00121 p.WriteHistory(*to); 00122 00123 // Place the input in the mosaic 00124 //p.StartProcess(outSample, outLine, outBand, priority); 00125 p.StartProcess(outSample, outLine, outBand); 00126 00127 if (bTrack != p.GetTrackFlag()) { 00128 ui.Clear("TRACK"); 00129 ui.PutBoolean("TRACK", p.GetTrackFlag()); 00130 } 00131 p.EndProcess(); 00132 00133 // Log the changes to NBANDS and to TRACK if any 00134 PvlObject hist = Isis::iApp->History(); 00135 Isis::iApp->Log(hist.FindGroup("UserParameters")); 00136 00137 // Logs the input file location in the mosaic 00138 for (int i = 0; i < p.imagePositions().Groups(); i++) { 00139 Application::Log(p.imagePositions().Group(i)); 00140 } 00141 } 00142 00143 /** 00144 * Initialize the mosaic to defaults 00145 * 00146 * @author sprasad (10/14/2009) 00147 * 00148 * @param buf 00149 */ 00150 void CreateMosaic(Buffer &buf) { 00151 for(int i = 0; i < buf.size(); i++) { 00152 buf[i] = NULL8; 00153 } 00154 }