Commit efcaf58d authored by Kim Oyama's avatar Kim Oyama
Browse files

Output the statistics used for the linear regression to the log. Updated...

Output the statistics used for the linear regression to the log. Updated documentation to correctly describe the POVERLAP option and to explain that this application only works on single band cubes. Fixes #1383.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5684 41f8697f-d340-4b68-9986-7bafba869bb8
parent e78fe432
Loading
Loading
Loading
Loading
+29 −3
Changes for isis/src/base/apps/tonematch/tonematch.cpp: 29 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -6,8 +6,11 @@
#include "UserInterface.h"
#include "IException.h"

#include <QList>

using namespace std;
using namespace Isis;

void getStats(vector<Buffer *> &in, vector<Buffer *> &out);
void toneMatch(Buffer &in, Buffer &out);

@@ -21,14 +24,20 @@ void IsisMain() {
  // Get the user interface
  UserInterface &ui = Application::GetUserInterface();

  // If the user selected pOverlap, get the projected overlap statistics
  if(ui.GetBoolean("POVERLAP")) {
    // Set up the overlap statistics object
  Cube from, match;
  from.open( ui.GetFileName("FROM") );
  match.open( ui.GetFileName("MATCH") );

  if( (from.bandCount() != 1) || (match.bandCount() != 1) ) {
    string msg = "tonematch only works for single band images.";
    throw IException(IException::User, msg, _FILEINFO_);
  }
  // If the user selected pOverlap, get the projected overlap statistics

  // Set up the overlap statistics object
  OverlapStatistics oStats(from, match);

  if( ui.GetBoolean("POVERLAP") ) {
    //Make sure the projections overlap
    if(!oStats.HasOverlap()) {
      string msg = "Input Cubes do not appear to overlap";
@@ -51,6 +60,19 @@ void IsisMain() {
  // compute the linear regression fit of the mvstats data
  stats.LinearRegression(base, mult);

  PvlGroup results("Results");
  QString stringNum = "";
  results += PvlKeyword( "Offset", stringNum.setNum(base) );
  results += PvlKeyword( "Gain", stringNum.setNum(mult) );
  Pvl fileOutput;
  fileOutput += results;
  fileOutput += oStats.toPvl();
  Application::Log(results);

  if (ui.WasEntered("OUTSTATS")) {
    fileOutput.write(ui.GetFileName("OUTSTATS"));
  }

  // Apply the correction
  p.ClearInputCubes();
  p.SetInputCube("FROM");
@@ -59,10 +81,14 @@ void IsisMain() {
  p.EndProcess();
}



void getStats(vector<Buffer *> &in, vector<Buffer *> &out) {
  stats.AddData(in[0]->DoubleBuffer(), in[1]->DoubleBuffer(), in[0]->size());
}



void toneMatch(Buffer &in, Buffer &out) {
  for(int i = 0; i < in.size(); i++) {
    if(Isis::IsSpecial(in[i])) {
+42 −10
Changes for isis/src/base/apps/tonematch/tonematch.xml: 42 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -2,14 +2,22 @@

<application name="tonematch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://isis.astrogeology.usgs.gov/Schemas/Application/application.xsd">
  <brief>
    Matches the tone of two images
    Matches the tone of two, single-band images
  </brief>

  <description>
    This application is very similar to the equalizer application, but is only used on two images.   
    Tonematch collects statistics on each individual cube.  It then uses this data to find a linear
    regression model between the input cube and the match cube.  The linear regression is 
    applied to the input cube, creating the output cube (whose tone is equal to that of the match cube).
    <p>This application matches the tone of two single-band images. It is very similar to the 
    equalizer application, but is only used on two images and only works on single band images. 
    The user can choose whether to match the tone of the entire image, or perform overlap matching
    using the projection information. The default behavior is to match the tones of the entire
    area of the input cube and the match cube.
    </p>

    <p>First, tonematch collects statistics on each individual cube. It then uses this data to 
    find a linear regression between the pixel values of the input cube and the match cube. The
    linear regression provides offset and gain values that are applied to the input cube, creating
    the output cube whose tone is equal to that of the match cube.
    </p>
  </description>

  <category>
@@ -35,6 +43,11 @@
    <change name="Elizabeth Miller" date="2006-02-10">
      Moved to Photometry and Radiometry group in documentation
    </change>
    <change name="Kimberly Oyama" date="2013-01-14">
      Output the statistics used for the linear regression to the log. Updated documentation to 
      correctly describe the POVERLAP option and to explain that this application only works on
      single band cubes. Fixes #1383.
    </change>
  </history>

  <groups>
@@ -43,7 +56,7 @@
        <type>cube</type>
        <fileMode>input</fileMode>
        <brief>
          Input cube 
          Input single band cube 
        </brief>
        <description>
          The pixels of the input cube will be altered using the base and multiplier found 
@@ -58,7 +71,7 @@
        <type>cube</type>
        <fileMode>input</fileMode>
        <brief>
          Match Cube
          Match Cube (single band)
        </brief>
        <description>
          The match cube will be used to find the tone that the output cube should have.
@@ -81,6 +94,24 @@
          *.cub
        </filter>
      </parameter>

      <parameter name="OUTSTATS">
        <type>filename</type>
        <fileMode>output</fileMode>
        <brief>
          Output text file containing thorough equalization-related
          statistics
        </brief>
        <description>
          This file will contain the statistics of the overlapping area along with the computed
          equalizing factors (OFFSET and GAIN). Since the output statistics are of the overlapping
          area, the POVERLAP option must be selected. Specifying this output file is optional.
        </description>
        <internalDefault>None</internalDefault>
        <filter>
          *.txt *.pvl *.lis *.lst
        </filter>
      </parameter>
    </group>

    <group name="Option">
@@ -90,11 +121,12 @@
          Projection Overlap
        </brief>
        <description>
          This parameter allows the user to match the tone of the entire images, or just match the overlapping
          area of the cubes.  If this option is chosen, both cubes must have the same projection parameters and
          must be overlapping.
          This parameter allows the user to match the tone of the overlapping area of the cubes
          instead of matching the tone of the entire area of both cubes. If this option is set to
          TRUE, both cubes must have the same projection parameters and must overlap.
        </description>
        <default><item>FALSE</item></default>
        <inclusions><item>OUTSTATS</item></inclusions>
      </parameter>
    </group>
  </groups>
+2 −2
Changes for isis/src/base/apps/tonematch/tsts/default/Makefile: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@ APPNAME = tonematch
include $(ISISROOT)/make/isismake.tsts

commands:
	 $(APPNAME) from= $(INPUT)/I00824006RDR.lev2.cub+1 \
	  match=$(INPUT)/I00824006RDR.lev2.cub+1 \
	 $(APPNAME) from= $(INPUT)/singleBand_I00824006RDR.lev2.cub \
	  match=$(INPUT)/singleBand_I00824006RDR.lev2.cub \
	  to=$(OUTPUT)/tonematchTruth1.cub > /dev/null;
+3 −3
Changes for isis/src/base/apps/tonematch/tsts/poverlap/Makefile: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ APPNAME = tonematch
include $(ISISROOT)/make/isismake.tsts

commands:
	 $(APPNAME) from= $(INPUT)/I00824006RDR.lev2.cub+1 \
	  match=$(INPUT)/I01523019RDR.lev2.cub+1 \
	 $(APPNAME) from= $(INPUT)/singleBand_I00824006RDR.lev2.cub \
	  match=$(INPUT)/singleBand_I01523019RDR.lev2.cub \
	  to=$(OUTPUT)/tonematchTruth2.cub \
	  poverlap=true > /dev/null;
	  poverlap=true outstats=$(OUTPUT)/outputStats.pvl> /dev/null;
+237 −238

File changed.

Preview size limit exceeded, changes collapsed.