void IsisMain() { // Setup the input and output cubes ProcessByLine p; // used for getting histograms from input cubes Cube *icube = p.SetInputCube("FROM", Isis::OneBand); p.SetOutputCube ("TO"); // Histogram parameters UserInterface &ui = Application::GetUserInterface(); double minimum = ui.GetDouble("MINPER"); double maximum = ui.GetDouble("MAXPER"); int increment = ui.GetInteger("INCREMENT"); // Histograms from input cubes Histogram *from = icube->Histogram(); Histogram *match = icube->Histogram(); double fromMin = from->Percent(minimum); double fromMax = from->Percent(maximum); int fromBins = from->Bins(); double data[fromBins]; double slope = (fromMax - fromMin) / (fromBins - 1); // Set "match" to have the same data range and number of bins as "to" match->SetBins(fromBins); match->SetValidRange(fromMin, fromMax); for (int i = 0; i < fromBins; i++) { data[i] = fromMin + (slope * i); } match->AddData(data, fromBins); stretch.ClearPairs(); double lastPer = from->Percent(minimum); stretch.AddPair(lastPer, match->Percent(minimum)); for (double i = increment+minimum; i < maximum; i += increment) { double curPer = from->Percent(i); if (lastPer < curPer) { if(abs(lastPer - curPer) > DBL_EPSILON) { stretch.AddPair(curPer, match->Percent(i)); lastPer = curPer; } } } double curPer = from->Percent(maximum); if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { stretch.AddPair(curPer, match->Percent(maximum)); } // Start the processing p.StartProcess(remap); p.EndProcess(); }
void IsisMain() { // Setup the input and output cubes along with histograms ProcessByLine p; Cube *mcube = p.SetInputCube("MATCH", Isis::OneBand); Histogram *match = mcube->Histogram(); p.ClearInputCubes(); Cube *icube = p.SetInputCube("FROM", Isis::OneBand); Histogram* from = icube->Histogram(); p.SetOutputCube ("TO"); // Histogram specifications UserInterface &ui = Application::GetUserInterface(); double minimum = ui.GetDouble("MINPER"); double maximum = ui.GetDouble("MAXPER"); stretch.ClearPairs(); // CDF mode selected if (ui.GetString("STRETCH") == "CDF") { int increment = ui.GetInteger("INCREMENT"); double lastPer = from->Percent(minimum); stretch.AddPair(lastPer, match->Percent(minimum)); for (double i = increment+minimum; i < maximum; i += increment) { double curPer = from->Percent(i); if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { stretch.AddPair(curPer, match->Percent(i)); lastPer = curPer; } } double curPer = from->Percent(maximum); if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { stretch.AddPair(curPer, match->Percent(maximum)); } } // Modal mode is selected else { stretch.AddPair(from->Percent(minimum), match->Percent(minimum)); stretch.AddPair(from->Mode(), match->Mode()); stretch.AddPair(from->Percent(maximum), match->Percent(maximum)); } // Start the processing p.StartProcess(remap); p.EndProcess(); }