ANSI-C program: cpx_math.c
NAME
cpx_math - Perform math operations on raster data files
(fcomplex format)
SYNOPSIS
cpx_math <d1> <d2> <d_out>
<width> <mode> [roff] [loff] [nr] [nl] [c_re] [c_im]
[zflg]
<d1> | (input) data file 1 (fcomplex) |
<d2> | (input) data file 2 (fcomplex) (enter - for none) NOTE: if no input file is provided, d2 values are set to value specified by c_re and c_im parameters |
<d_out> | (output) output of math operation on d1 and d2 (fcomplex) |
<width> | number of samples/line |
<mode> | math operation to perform on the data 0: complex addition, d1 + d2 1: subtraction, d1 - d2 2: multiplication, d1 * d2 3: division, d1/d2 |
[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) |
[c_re] | constant real component (enter - for default: 1.18e-38 for addition and subtraction, 1.0 for multiplication and division) |
[c_im] | constant imaginary component (enter - for default: 0.0) |
[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 |
NOTE: when specifying a reference region with
roff, loff, nr, nl parameters: modes 0, 1: reference region average value is subtracted from d1 and d2 data respectively modes 2, 3: d1 and d2 data are divided by the average in the reference region |
EXAMPL
cpx_math s1.diff s2.diff
s3.diff 600 1 425 270 16 16
DESCRIPTION
cpx_math evaluates arithmetic operations between data files of type fcomplex (32-bits/sample real, imaginary). 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 + 0.0i 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 + 0.0i, the output pixel value is 0.0+0.0i (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 for the real value (1.18e-38) to avoid the pixel being considered as no-data.
If zflg is 1, then 0.0+0.0i is considered valid data. For the special case of division when zflg = 1, and the value of d2 is 0.0+0.0i, the output pixel value is set to 0.0 + 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 values c_re + c_im i specified on the command line. In the case where - or no value is given for the constant real and imaginary components, default values of 1.18e-38 + 0.0i for addition and subtraction or 1.0 + 0.0i for multiplication and division are set.