Commit 8347434b authored by Adam Paquette's avatar Adam Paquette
Browse files

Updated HistogramTool to properly analyze the pixels selected using the...

Updated HistogramTool to properly analyze the pixels selected using the rectangular selection. Fixes #2155.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6904 41f8697f-d340-4b68-9986-7bafba869bb8
parent 62464df2
Loading
Loading
Loading
Loading
+24.6 KiB (58.4 KiB)
Loading image diff...
−11.6 KiB (7.98 KiB)
Loading image diff...
+59 −19
Original line number Diff line number Diff line
@@ -13,8 +13,48 @@ using namespace Isis;
void isis2ascii(Buffer &in);
ofstream fout;

class SpecialPixelFunctor{

public:
    explicit SpecialPixelFunctor(QString null,
                                 QString hrs,
                                 QString his,
                                 QString lrs,
                                 QString lis) :
        null(null), hrs(hrs), his(his), lrs(lrs), lis(lis) {}

    void operator() (Buffer &in) const {
        for(int i = 0; i < in.size(); i++) {
          fout.width(13);        //  Width must be set everytime
          if(IsSpecial(in[i])) {
            if(IsNullPixel(in[i])) fout << null;
            if(IsHrsPixel(in[i])) fout << hrs;
            if(IsHisPixel(in[i])) fout << his;
            if(IsLrsPixel(in[i])) fout << lrs;
            if(IsLisPixel(in[i])) fout << lis;
          }
          else {
            fout << in[i];
          }
        }
        fout << endl;
    }
private:
    QString null;
    QString hrs;
    QString his;
    QString lrs;
    QString lis;
};

void IsisMain() {
  // Create a process by line object
  QString null;
  QString hrs;
  QString his;
  QString lrs;
  QString lis;

  ProcessByLine p;

  // Get the size of the cube
@@ -32,29 +72,29 @@ void IsisMain() {
         icube->lineCount() << ":" << icube->bandCount() << endl;
  }

  //Determine special pixel values
  if (ui.GetBoolean("SETPIXELVALUES")) {
    null = ui.GetString("NULLVALUE");
    hrs = ui.GetString("HRSVALUE");
    his = ui.GetString("HISVALUE");
    lrs = ui.GetString("LRSVALUE");
    lis = ui.GetString("LISVALUE");
  }
  else {
    null = "NULL";
    hrs = "HRS";
    his = "HIS";
    lrs = "LRS";
    lis = "LIS";
  }

  SpecialPixelFunctor isis2ascii(null, hrs, his, lrs, lis);
  
  fout << std::setprecision(7);
  
  // List the cube
  p.StartProcess(isis2ascii);
  p.ProcessCubeInPlace(isis2ascii, false);
  p.EndProcess();

  fout.close();
}

void isis2ascii(Buffer &in) {
  for(int i = 0; i < in.size(); i++) {
    fout.width(13);        //  Width must be set everytime
    if(IsSpecial(in[i])) {
      if(IsNullPixel(in[i])) fout << "NULL";
      if(IsHrsPixel(in[i])) fout << "HRS";
      if(IsHisPixel(in[i])) fout << "HIS";
      if(IsLrsPixel(in[i])) fout << "LRS";
      if(IsLisPixel(in[i])) fout << "LIS";
    }
    else {
      fout << in[i];
    }
  }
  fout << endl;

}
+107 −5
Original line number Diff line number Diff line
@@ -3,11 +3,14 @@
  <brief> Export cube to an ascii file</brief>

  <description>
    This program will print the cube data to an ascii file.  Special pixels will be represented
    as NULL, LIS, LRS, HIS and HRS.  If you do not want special pixels in your ascii output,
    run the program "stretch" to replace their value.  If there are multiple bands in the cube,
    they will be output in band sequential format.  Beware:  The output file will be roughly
    3 times as big as the input.
    This program converts sn ISIS cube to ASCII file format.  Special pixels such as
    <def>NULL</def>, <def>LIS</def>, <def>LRS</def>, <def>HIS</def> and <def>HRS</def> 
    have predetermined pixel values. You may opt to assign a range of pixel values to 
    the individual <def>Special Pixels</def> using the SETPIXELVALUES parameter. Bands in the cube 
    will be output in band sequential format.
    <br />
    <br />
    Beware: The output file will be roughly 3 times as big as the input.
  </description>

  <category>
@@ -65,6 +68,9 @@
    <change name="Makayla Shepherd" date="2015-01-30">
      Increased precision of the DNs in the output text file from 6 to 7
    </change>
    <change name="Adam Paquette" date="2016-06-15">
      Added the ability for a user to specify the special pixel values
    </change>
  </history>


@@ -103,6 +109,102 @@
        </default>
      </parameter>
    </group>

    <group name="Special Pixels">
      <parameter name="SETPIXELVALUES">
        <type>boolean</type>
	<default>
	  <item>NO</item>
	</default>
	<brief>User defined output for special pixels</brief>
	<description>
	      Determine whether the user would like a 
	      specific output for the special pixels in the image.
	</description>
	<inclusions>
	  <item>NULLVALUE</item>
	  <item>LRSVALUE</item>
	  <item>LISVALUE</item>
          <item>HISVALUE</item>
	  <item>HRSVALUE</item>
	</inclusions>
      </parameter>
      
      <parameter name="NULLVALUE">
	<type>string</type>
	<default>
	  <item>NULL</item>
	</default>
	<brief>Value to set to any null pixel</brief>
	<description>
	    Value that will replace any null pixel within a cub with
	    the number entered. Defaults to NULL if nothing is entered.
	</description>
	<inclusions>
	  <item>SETPIXELVALUES</item>
	</inclusions>
      </parameter>

      <parameter name="LRSVALUE">
        <type>string</type>
        <default>
          <item>LRS</item>
        </default>
        <brief>Value to set to any LRS pixel</brief>
        <description>
            Value that will replace any LRS pixel within a cub with
            the number entered. Defaults to LRS if nothing is entered.
        </description>
        <inclusions>
          <item>SETPIXELVALUES</item>
        </inclusions>
      </parameter>

      <parameter name="LISVALUE">
        <type>string</type>
        <default>
          <item>LIS</item>
        </default>
        <brief>Value to set to any LIS pixel</brief>
        <description>
            Value that will replace any LIS pixel within a cub with
            the number entered. Defaults to LIS if nothing is entered.
        </description>
        <inclusions>
          <item>SETPIXELVALUES</item>
        </inclusions>
      </parameter>

      <parameter name="HISVALUE">
        <type>string</type>
        <default>
          <item>HIS</item>
        </default>
        <brief>Value to set to any HIS pixel</brief>
        <description>
            Value that will replace any HIS pixel within a cub with
            the number entered. Defaults to HIS if nothing is entered.
        </description>
        <inclusions>
          <item>SETPIXELVALUES</item>
        </inclusions>
      </parameter>

      <parameter name="HRSVALUE">
        <type>string</type>
        <default>
          <item>HRS</item>
        </default>
        <brief>Value to set to any HRS pixel</brief>
        <description>
            Value that will replace any HRS pixel within a cub with
            the number entered. Defaults to HRS if nothing is entered.
        </description>
        <inclusions>
          <item>SETPIXELVALUES</item>
        </inclusions>
      </parameter>
     </group>
  </groups>

  <liens>
+14 −0
Original line number Diff line number Diff line
APPNAME = isis2ascii

include $(ISISROOT)/make/isismake.tsts
vesta64ascii.txt.SKIPLINES = 1


commands:
	$(APPNAME) from = $(INPUT)/isisTruth.cub \
	  to = $(OUTPUT)/isisTruthAsciiUser_temp.txt setpixelvalues = yes \
	  nullvalue = 0 lrsvalue = 0 lisvalue = 0 hisvalue = 255 \
	  hrsvalue = 255 > /dev/null;
	$(SED) 's+/.*/input/+input/+' $(OUTPUT)/isisTruthAsciiUser_temp.txt > $(OUTPUT)\
	/isisTruthAsciiUser.txt;
	$(RM) $(OUTPUT)/isisTruthAsciiUser_temp.txt;
 No newline at end of file