STR

Image Contrast Stretch


EnvironmentsPYTHON :: EASI :: MODELER
Batch ModeYes
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Algorithm

Back to top

Description


STR generates a lookup table segment to perform contrast stretching of image data on database files.
Back to top

Parameters


Name Type Length Value range
Input: Raster Layer: Input raster channel or layer Raster port 0 - 1  
Output: Lookup Table Layer: Lookup table segment or layer LUT port 0 - 1  
LUT Layer Name String 0 - 1  
Layer Description String 0 - 1  
Exponent Float 0 - 1 0.0 - 100.0
Default: 0.5
Min Out gray Level Integer 0 - 1 0 - 255
Max Out gray Level Integer 0 - 1 0 - 255
Low End Control String 1 - 1 OFF, MIN, MAX
Default: MIN
High End Control String 1 - 1 OFF, MIN, MAX
Default: MAX
Trim Left Real 0 - 1 0.0 - 100.0
Trim Right Real 0 - 1 0.0 - 100.0
Mask: Area Mask: Area mask Bitmap port 0 - 4 Xoffset, Yoffset, Xsize, Ysize
LASC Integer 0 - 1  
Resample Mode String 0 - 1 Nearest, Bilinear, Cubic
Default: Nearest

* Required parameter
Back to top

Parameter descriptions

Input: Raster Layer: Input raster channel or layer

Specifies the input channel from which "actual" minimum and maximum gray levels for stretching are determined.

Output: Lookup Table Layer: Lookup table segment or layer

Specifies the lookup table segment or layer to receive the function.

DBLUT (Input) may contain one or no elements. If this parameter is explicitly specified, the lookup table segment must be of type 170 or 172 and will be overwritten. If it is not specified, then a new lookup table segment is created.

Upon completion, DBLUT returns the number of the segment used to save the created lookup table function.

LUT Layer Name

Specifies a name (up to 8 characters) for the output lookup table (LUT) segment or layer. This parameter is only used if a new segment is created.

Layer Description

Optionally describes (in up to 64 characters) the contents or origins of the output segment lookup table (LUT) segment or layer. This parameter is only used if a new segment is created.

Exponent

Specifies a positive real number corresponding to the exponent in the following contrast stretching formula:

newval = A*(oldval - ISTR(1))**EXPO + OSTR(1)

where newval and oldval are gray levels, A is the scaling factor, and ISTR(1) and OSTR(1) are the minimum input and output gray levels.

For example, if EXPO (Exponent) is set to 1, the stretch is linear.

Any floating point number between 0.0 and 100.0 can be specified. The default value for this parameter is 0.5, which eliminates the typical skewing of histograms.

Min Out gray Level

Specifies the minimum output gray levels. Valid values are between 0 and 255.

Max Out gray Level

Specifies the minimum output gray levels. Valid values are between 0 and 255, and the value specified must be greater than or equal to the minimum output gray level.

Low End Control

Specifies the mapping of pixels that fall short of the minimum input gray level.

Valid values are:

High End Control

Specifies the mapping of pixels that are higher than the maximum input gray level.

Valid values are:

Trim Left

Optionally specifies the amount of low tail trimming to apply to the image histogram sample.

Valid values include real values in units of % between 0 and 100.

Trim Right

Optionally specifies the amount of high tail trimming to apply to the image histogram sample.

Valid values include real values in units of % between 0 and 100.

Mask: Area Mask: Area mask

Specifies the window or bitmap that defines the area to be stretched within the input raster. If this parameter is not specified, the entire channel (layer) is used by default. Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height.

LASC

If a new segment is created, then LASC is assigned the number for the new segment, after STR has finished executing.

Resample Mode

Specifies the type of resampling method that is used.

Resampling extracts and interpolates the gray levels from the original pixel locations to corrected locations.

Three resampling modes are supported.

The default value is Nearest.

Back to top

Details

STR generates custom-made lookup table segments (type 170 or 172), which can then be used by LUT to perform contrast stretching functions on image data stored in specified database channels. In general, the user has total control of the parameters that make up the contrast stretch function. The range of input values for the lookup table function can be determined from an input channel or can be set manually by the user. The range of output values for the lookup table function can be defaulted to the full gray-scale range (0-255), or specified over a user-selected range. Input image data between the minimum and maximum values are mapped using a power function with a specified exponent. The LCTR (Low End Control) and HCTR (High End Control) parameters control the mapping function for input values that are outside the input gray level value range.

A bitmap specifies the area within the input channel that will be processed. Only this area will be filtered and the rest of the image will be unchanged. If no bitmap is connected, the entire database is processed.

Sampling may be further restricted using the Trim Left and Trim Right parameters, which trim the low and high ends of the sample by specified percentages. These parameters are useful for eliminating outliers or noise.

If all parameters are defaulted, STR performs the "default enhancement", a square-root function which exaggerates contrast in the low end of the gray-level spectrum. gray-level values are transformed such that the minimum and maximum gray-level values on the input image are mapped to 0 and 255 respectively on the output image.

Functions

Various types of functions can be obtained by varying the value of the exponent:

 EXPO = 0.5     Square root function (default)
 EXPO = 1       Linear ramp function
 EXPO = 2       Squaring function

In general, the user has total control of the parameters that make up the contrast stretch function. All default minimum and maximum input and output values can be overridden by user-specified values .

The area under which the image is sampled to determine the minimum and maximum input values can be restricted to a specified mask window or under a specified database. The low and high ends of this sample can be trimmed by specified percentages to eliminate outliers or noise.

Back to top

Algorithm

The contrast stretch function has the following form:

  F(X) = A * (X - ISTR(1)) ** EXPO + OSTR(1) 
                                        ISTR(1) < X < ISTR(2)

 X              Input gray-level value
 F(X)           Output gray-level value
 A              Scaling factor
 EXPO           Power exponent (must be positive value)
 ISTR(1)        Minimum input gray-level value (must be <= ISTR(2))
 ISTR(2)        Maximum input gray-level value (must be >= ISTR(1))
 OSTR(1)        Minimum output gray-level value
 OSTR(2)        Maximum output gray-level value

 If OSTR(1) > OSTR(2), the result is a `negative' image.

The formula for determining the scaling factor A is as follows:


                OSTR(2) - OSTR(1)
        A = ---------------------------
            (ISTR(2) - ISTR(1)) ** EXPO

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.