Isis 3.0 Application Source Code Reference |
Home |
00001 #include "Isis.h" 00002 #include "ProcessByLine.h" 00003 #include "SpecialPixel.h" 00004 #include "Statistics.h" 00005 #include "Stretch.h" 00006 #include "Histogram.h" 00007 00008 using namespace std; 00009 using namespace Isis; 00010 00011 Stretch stretch; 00012 00013 void remap(vector<Buffer *> &in, vector<Buffer *> &out); 00014 00015 void IsisMain() { 00016 // Setup the input and output cubes along with histograms 00017 ProcessByLine p; 00018 Cube *mcube = p.SetInputCube("MATCH", Isis::OneBand); 00019 Histogram *match = mcube->getHistogram(); 00020 p.ClearInputCubes(); 00021 Cube *icube = p.SetInputCube("FROM", Isis::OneBand); 00022 Histogram *from = icube->getHistogram(); 00023 p.SetOutputCube("TO"); 00024 00025 // Histogram specifications 00026 UserInterface &ui = Application::GetUserInterface(); 00027 double minimum = ui.GetDouble("MINPER"); 00028 double maximum = ui.GetDouble("MAXPER"); 00029 00030 stretch.ClearPairs(); 00031 00032 // CDF mode selected 00033 if(ui.GetString("STRETCH") == "CDF") { 00034 int increment = ui.GetInteger("INCREMENT"); 00035 double lastPer = from->Percent(minimum); 00036 stretch.AddPair(lastPer, match->Percent(minimum)); 00037 for(double i = increment + minimum; i < maximum; i += increment) { 00038 double curPer = from->Percent(i); 00039 if(lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { 00040 stretch.AddPair(curPer, match->Percent(i)); 00041 lastPer = curPer; 00042 } 00043 } 00044 double curPer = from->Percent(maximum); 00045 if(lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { 00046 stretch.AddPair(curPer, match->Percent(maximum)); 00047 } 00048 } 00049 00050 // Modal mode is selected 00051 else { 00052 stretch.AddPair(from->Percent(minimum), match->Percent(minimum)); 00053 stretch.AddPair(from->Mode(), match->Mode()); 00054 stretch.AddPair(from->Percent(maximum), match->Percent(maximum)); 00055 } 00056 00057 // Start the processing 00058 p.StartProcess(remap); 00059 p.EndProcess(); 00060 } 00061 00062 // Adjust FROM histogram to resemble MATCH's histogram 00063 void remap(vector<Buffer *> &in, vector<Buffer *> &out) { 00064 Buffer &from = *in[0]; 00065 Buffer &to = *out[0]; 00066 00067 for(int i = 0; i < from.size(); i++) { 00068 to[i] = stretch.Map(from[i]); 00069 } 00070 } // end remap