Gamma DISP: Reference Manual


float_math

ANSI-C program: float_math.c

NAME
float_math -  Perform math operations on raster data files (float format)

SYNOPSIS
float_math <d1> <d2> <d_out> <width> <mode> [roff] [loff] [nr] [nl] [c0] [zflg]

<d1> (input) data file 1 (float)
<d2> (input) data file 2 (float) (enter - for none)
NOTE: if no input file is provided, d2 values are set to value specified by c0 parameter
<d_out> (output) output of math operation on d1 and d2 (float)
<width> number of samples/line
<mode> math operation:
     0:  addition, d1 + d2
     1:  subtraction, d1 - d2
     2:  multiplication, d1 * d2
     3:  division, d1/d2
     4:  10 * log10(d1), evaluate dB value
     5:  d1*d1
     6:  sqrt(d1)
[roff] range pixel offset to center of the reference region (enter - for default: no reference correction)
[loff] line offset to center of the reference region (enter - for default: no reference correction)
[nr] number of range pixels to average in the reference region (enter - for default: 13)
[nl] number of lines average in the reference region (enter - for default: 13)
[c0] constant value (enter - for default: 1.18e-38 for addition and subtraction, 1.0 for multiplication and division)
[zflg] zero data flag:
  0: values of 0.0 in d1 or d2 are considered as no-data and the output is set to 0.0 (default)
  1: values of 0.0 are considered as valid data

EXAMPLES

float_math hector_1.pix hector_2.pix diff.pix 2456 1 - - - - 1

Evaluate the difference between the files hector_1.pix and hector_2.pix and store the result in the file diff.pix. The width of the each line is 2456 samples. Values of 0.0 in hector_1.pix or hector_2.pix are considered as valid data.

float_math s1.diff s2.diff s3.diff 600 0 425 270

add the data files s1.diff and s2.diff and place the sum in s3.diff. Each line of s1 and s2 is 600 samples wide.  The reference area is centered on sample 425 in range and line 270. The region that is averaged is 16 samples wide and has 16 lines.  The average value of the reference are in s1 is subtracted from s1 and similarly for s2.

DESCRIPTION

float_math evaluates arithmetic operations between data files of type float (32-bits/sample). The input data files d1 and d2 must have the same line width specified by the width command line parameter. The operations of addition, subtraction, multiplication, and division are supported.

The user can specify a reference region for the two images to perform normalization of the data. The average of the data in the reference region is evaluated for each scene and used to remove a bias or normalize the data. This is particularly useful for removal of a interferogram phase offset at a particular position in the image chosen as the phase reference location.  

For the addition or subtraction modes the average of d1 in the reference area is subtracted from d1 and the average of d2 in the reference area is subtracted from d2.  In the case of multiplication or division, the data files d1 and d2 are divided by the averages of their respective reference regions.

The zflg command line parameter determines how values of 0.0 in the data are handled. If zflg is the default value of 0, then if either of the input files has a value of 0.0, the output pixel value is 0.0 (no-data). Also when zflg = 0 for the case where the operations of addition or subtraction lead to a value that is exactly 0.0, then the output value is replaced with the smallest floating point value (1.18e-38) to avoid the pixel being considered as no-data

If zflg is 1, then 0.0 is considered valid data. For the special case of division when zflg = 1,  and the value of d2 is 0.0,  the output pixel value is set to 0.0 (no-data) and not NaN

Instead of reading a file for the values d2, it is possible to enter  -.  In this case, the d2 values are set to the constant value c0 specified on the command line. In the case where - or no value is given for the constant, a default value of 1.18e-38 for addition and subtraction or 1.0 for multiplication and division is set.

mode 4 is for conversion of intensity data to dB values. If the input is  equal to 0.0, the output is set to 0.0, otherwise the dB conversion is performed on the absolute value of the data value.

mode 5 generates the square of input file d1.

mode 6 calculates the square root of the absolute value of d1. 

NOTE: when specifying a reference region with roff, loff, nr, nl parameters:

modes 0, 1:  The reference region average value for for d1 is subtracted from d1 and the average in the reference region is subtracted from d2.

modes 2, 3:    d1 and d2 data are divided by the average in the reference region in each of the data sets

modes 4,5,6:  data values in d1 are divided by the average value in the reference region prior to the operation


© Copyrights for Documentation, Users Guide and Reference Manual by Gamma Remote Sensing, 2014.
UW, CW, TS, last change 4-Nov-2014.