Help for FIT

PURPOSE:

FIT is a VICAR applications program which performs automatic linear
stretches on halfword pictures anywhere in the halfword range (-32768
to +32767).  

Description of the Auto-stretch Algorithm:

FIT computes a grey level frequency table (histogram) of the input 
image.  The histogram has 65536 bins, hence spans the entire halfword
range from -32768 to +32767 

If EXCLUDE=(N1,N2) is specified, the histogram is modified by setting:

	H(I) = 0 for N1 <= I <= N2

If the INCLUDE keyword is not specified, the histogram element corresponding
to 0 DN is set to zero also.
                                                      I2
                                                     ---
Define the area function A:	      A(I1,I2) =     \     H(I)
                                                     /
        ^                                            ---
        |                                           I=I1	
        |
        |
        |                        _--_    __
     H  |                      _-    -__-  -_
        |                    _-              -_
        |                  _-                  -_
        |                _-                      -_
        |              _-|                        |#-_
        |           _-###|                        |###-__
        |        __-#####|                        |######-_____
        ---|-------------|------------------------|-----------------|---->
        -32768         IMIN                     IMAX              32767  I
The program determines linear stretch constants IMIN and IMAX such that:

 a) IMIN is the largest I which satisfies the equation
       A(-32768,I) <= PL * A(-32768,32767)

 b) IMAX is the smallest I which satisfies the equation
       A(I,32767) <= PH * A(-32768,32767)

where PL and PH may be specified by the LPER and HPER keywords.  The values
A(-32768,IMIN) and A(IMAX,32767) represent the shaded areas under the curve in 
the above graph.  Note that A(-32768,32767) is the total histogram area, and 
represents the number of samples in the image which have not been excluded.
The linear stretch which is applied to the image is defined as follows:
	
	     HV - LV
     Y =   -----------	(X - IMIN) + LV
	   IMAX - IMIN

where X and Y are the input and output DN values respectively for each
pixel.
Description of Printed Histograms and Statistics:

After computing the histogram, the mean and standard deviation of the 
input image are printed out.

If the keyword PHIST is specified, the histogram is printed out.  Since
it is normally undesirable to print all the grey levels, the histogram
is condensed so that a maximum of NLIN grey levels are printed. 
This is accomplished by determining a suitable increment M.  Alternatively, 
the increment M may be specified via the HINC parameter.  The condensed
histogram H* may be interpreted as follows:

	H* (I) = H(I) + H(I+1) + ... + H(I+M-1)

	    for I = 1, M + 1, 2 * M + 1, ...

	H* (I) = 0 for all other I.

After zeroing out the excluded elements from the histogram, the mean and
standard deviation computed from the excluded histogram are printed out.  
If EHIST is specified, the excluded histogram is printed out.  Same 
comments as above apply.
The input for FIT can be any organization, BSQ, BIL, or BIP.  If an output
is desired, it will have the same organization as the input.

EXAMPLES:

	FIT  INP=A  OUT=B   'BYTE   PERC=1.

The halfword image contained in data set A is scaled to 8 bits, saturating
0.5 percent of the data at both ends of the histogram.

	FIT INP=A  'PHIST 

The halfword histogram is printed.  No output image is produced.

	FIT  INP=A OUT=B  'BYTE  PERC=1.0  EXCL=(12001,32767)

The halfword image contained in A is scaled to 8 bits as in Example 1.
However, all sample values less than 1 or greater than 12000 are 
ignored in the auto-stretch computation.
PROGRAMMING HISTORY
WRITTEN BY:			GARY YAGI	2 SEPT 1982
CONVERTED TO VAX BY:		J. A. MOSHER	JUNE 1985
CURRENT COGNIZANT PROGRAMMER:	S. POHORSKY

PARAMETERS:


INP

Halfword disk data set input

OUT

The stretched version of INP (optional)

SIZE

VICAR size field (SL,SS,NL,NS)

SL

Starting Line of input image.

SS

Starting Sample of input image.

NL

Number of lines

NS

Number of samples

OFORM

Output data format. Valid: BYTE,HALF

SPEED

Line increment for histogram

PERCENT

percentage of histogram to be saturated.

LPERCENT

percentage of lower end of histogram to be saturated.

HPERCENT

percentage of higher end of histogram to be saturated.

HVALUE

input histogram upper saturation DN mapped to HVAL.

LVALUE

input histogram lower saturation DN mapped to LVAL.

AREA

(SL,SS,NL,NS) - field of image for histogram computation.

EXCLUDE

2-200 INTEGERS - exclude the DNs within the specified range.

INCLUDE

0 DN is to be included in auto-stretch computation.

PHIST

print histogram of input image

EHIST

Excluded histogram is to be printed out

SPIKE

Specifies the number of spikes in the histogram

LOG

Frequency axis of printed histogram is logrithmicaly scaled

NLIN

number of grey levels/lines in printed histogram

HINC

grey level increment factor for printed histogram

SB

starting band

NB

number of bands

BRANGE

starting band and number of bands to use for histogram

See Examples:


Cognizant Programmer: