This function constructs an ENVIRaster from a source raster that has an optimized linear stretch applied. This is similar to a linear stretch but provides more settings to control midtones, shadows, and highlights in an image. It computes the stretch minimum and maximum based on four values that ENVI sets by default. See the Stretch Type Background topic for details.

The result is a virtual raster, which has some additional considerations with regard to methods and properties. See Virtual Rasters for more information, including how they differ from ENVITasks.

The equivalent task is OptimizedLinearStretchRaster.


; Start the application
e = ENVI()
; Open a file
filename  = FILEPATH('qb_boulder_msi', $
raster = e.openraster(filename)
; Create the stretch raster
stretchRaster = ENVIOptimizedLinearStretchRaster(raster, $
; Display the results
view = e.GetView()
layer = view.CreateLayer(stretchRaster)


Result = ENVIOptimizedLinearStretchRaster(Input_Raster, BRIGHTNESS=value)

Return Value

This routine returns an ENVIRaster that has had an Optimize Linear stretch applied.



Specify the input ENVIRaster.


This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:




BRIGHTNESS (optional)

Set this keyword to an integer value from 0 to 100, indicating the brightness level to display. The default value is 50 if no brightness is specified. You can also set this value to a scalar or an array with the same number of elements as the raster has bands.


Specify a string that identifies the raster.

Version History

ENVI 5.2


ENVI 5.3.1

Documented the dehydrated form of this virtual raster

ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

API Version


See Also

OptimizedLinearStretchRaster Task, ENVIEqualizationStretchRaster, ENVIGaussianStretchRaster, ENVILinearPercentStretchRaster, ENVILinearRangeStretchRaster, ENVILogStretchRaster, ENVIRaster, ENVIRootStretchRaster