Help for STRETCH

    STRETCH is a VICAR application program which changes the point by point 
intensity of an image by generating a transfer function on the domain of
intensity values.  Seventeen types of stretches are available. These are:

                        Non-Histogram Stretches
                        -----------------------
    COMP,LINEAR,CLIP,CONTOUR,ALARM,GAMMA,TABLE,ITABLE,PSTRETCH,FUNCTION 

                         Histogram Stretches
                         -------------------
            SMOOTH,GAUSS,ELLIPSE,POWER,PEAK,MEAN,ASTRETCH

The default operation, if no operation is specified, is to perform an 
auto-stretch with 6 percent saturation at both the low and high ends.
This is equivalent to specifying 'ASTRETCH PERCENT=12.

     In those cases where a histogram is required, STRETCH generates the 
histogram of the input image according to the AREA and LINC parameters. 
Alternatively, the histogram of the input image, (generated by the program 
HISTGEN), may be supplied as a second input to STRETCH. This permits the 
program to omit reading the input image to accumulate a histogram, or to
stretch one image based upon the statistics of another. Only one pass through 
the image is needed, therefore, to generate the stretched output image. The 
histogram is then modified according to the REXCLUDE, IEXCLUDE, INCLUDE, and 
CUT parameters by setting the frequencies of all excluded DN values to zero. 
0 AND THE MAXIMUM DN ARE ALWAYS EXCLUDED UNLESS THE 'INCLUDE' KEYWORD IS 
SPECIFIED. (The maximum DN is 255 for byte data and 32767 for halfword data.)
This modified histogram is then used to generate the required stretch values.

     The input image may be either byte or halfword. The output image will be 
the same format as the input.  The user may specify the DN range of the data 
by using the DNMIN and DNMAX parameters.


     An optional linear post stretch may be performed following the initial 
stretch. This post stretch will take the output image DN values ranging from 
DNMIN to DNMAX to a user specified DN range. This post stretch does not require
a separate pass through the data. Instead, the initial stretch and the post
stretch are incorporated in a single look-up table which is then used to process
the input data.
 RESTRICTIONS:

          1. Only one of the seventeen types of stretches
             available may be specified in a single execution.
          2. Input image must be in either byte or halfword
             format.
          3. DNMIN must be less than or equal to 0 unless
             a HISTGEN histogram data set is supplied as
             a second input, in which case DNMIN must be 0.
          4. If a post-stretch is requested the values
             specified must be in the range DNMIN to DNMAX.
          4. Histograms, CDF's, and the final lookup table
             are printed only in the case of byte data.

EXECUTION:

   The following is the execution statement for STRETCH:
          STRETCH  INP  OUT  PARAMS
where INP, OUT, and PARAMS are parameters discussed in their
respective parameter section in TUTOR mode.

EXAMPLES:     

    STRETCH A B LINEAR=(50,100)  Performs linear stretch such that
                                 a DN of 50 becomes 0 and a DN of
                                 100 becomes 255. (A is byte)

    STRETCH A B FUNC="2*DN"      Output DN values will be twice the 
                                 input DN values. (Values greater
                                 than 255 are set to 255, again
                                 A is byte)

    STRETCH A B 'IHIST 'OHIST    The default stretch, an auto-stretch
                                 with six percent saturation at both 
                                 ends is performed and both the input 
                                 and output histograms are printed.
                                 0 AND 255 ARE EXCLUDED FROM BOTH HISTOGRAMS.
                                 (A is byte)

    STRETCH A2 B2 DNMAX=1000     The default auto-stretch is performed.
                                 (A2 is halfword) The maximum DN value
                                 expected is 1000. Any points with 
                                 a DN value higher than this will be 
                                 treated as having a value of 1000. 
                                 Six percent of the data will be 
                                 saturated at a DN value of 1000 and
                                 six percent will be saturated at a 
                                 DN value of 0.
                                 0 AND 255 ARE EXCLUDED FROM BOTH HISTOGRAMS.

    STRETCH A2 B2 POST=(0,255)   The default auto-stretch is performed.
                                 (A2 is halfword) Six percent of the
                                 data will be saturated at a DN value
                                 of 32767 and six percent will be
                                 saturated at a DN value of 0. 
                                 0 AND 32767 ARE EXCLUDED FROM BOTH HISTOGRAMS.
                                 The resulting values will then be linearly
                                 stretched such that 0 goes to 0 and
                                 32767 goes to 255.
                                 (The output remains halfword)
 TIMING: None available 
 WRITTEN BY:               J. H. Reimer       10/31/85
 BASED ON:   ASTRTCH2 by   A. A. Schwartz     08/03/71
             STRETCH  by   T. C. Rindfleish   04/21/69
 COGNIZANT PROGRAMMER:     Ron Alley           3/01/91

 REVISION:                 5                   3/30/01


PARAMETERS:


INP

Input dataset and (optional) histogram dataset

OUT

Output data set

SIZE

Size field = (SL,SS,NL,NS)

SL

Starting line

SS

Starting sample

NL

Number of lines

NS

Number of samples

LINEAR

Linear stretch supply MIN, MAX

CLIP

Bit shift stretch - supply # of bits. (Neg=Right Pos=Left)

CONTOUR

Contour stretch - needs contour interval [See DNVALUE]

POWER

Power law histogram stretch Supply power value (>0.0)

FUNCTION

User specified function stretch (Example: FUNC="2*DN+1")

ALARM

Alarm stretch - list DN's to alarm [See DNVALUE]

GAMMA

Gamma stretch Supply value of gamma

TABLE

Table stretch (N Pairs of values - In, Out, In, Out, In, Out,...) [See BACKGND]

ITABLE

Individual table stretch (N Pairs of values - In, Out, In, Out, In, Out,...) [See BACKGND]

POST

Post-stretch option supply MIN, MAX

OTHER

Other stretch options Valid: ASTRETCH, GAUSS, SMOOTH, MEAN, PEAK, COMP, PSTRETCH, ELLIPSE

DNVALUE

DN value used for CONTOUR and ALARM stretches

BACKGND

Background DN value used for TABLE and ITABLE stretches

PERCENT

Total percentage of image to be saturated. Used in ASTRETCH, MEAN, PEAK stretches.

LPERCENT

Percentage of image to be saturated at the low end. Used in ASTRETCH stretch.

HPERCENT

Percentage of image to be saturated at the high end. Used in ASTRETCH stretch.

GSIGMA

# of std deviations for GAUSS

RANGE

Range for PEAK or MEAN stretch

FACTOR

Scaling for PEAK / MEAN stretch

FREQ

Frequency for PSTRETCH stretch

AMPL

Amplitude for PSTRETCH stretch

PHI

Phase for PSTRETCH stretch

DC

Mean for PSTRETCH stretch

REXCLUDE

Range of DNs to exclude from stretch

IEXCLUDE

Individual DNs to exclude from stretch. 0 AND THE MAXIMUM DN ARE ALWAYS EXCLUDED UNLESS INCLUDE KEYWORD IS SPECIFIED.

INCLUDE

Include 0 and the maximum DN in the histogram for the automatic stretch?

DNMIN

Minimum DN value

DNMAX

Maximum DN value

AREA

area used to calculate histogram, input as sets of (SL, SS, NL, NS)

LINC

Line subsampling used in computing histogram

HIST

Histogram print options VALID: IHIST, OHIST, ICDF, OCDF More than one may be used

SPIKES

# spikes in printed histogram

CUT

Exclude DN's with frequency of occurence less than N% of maximum frequency count

PARMS

Parameter data set name

See Examples:


Cognizant Programmer: