This function constructs an ENVIRaster from a source raster that has been transformed from a red/green/blue (RGB) to hue/saturation/intensity (HSI) color space. The HSI color space is often used to identify features in image-processing algorithms that are more intuitive and natural to the human eye.

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 RGBToHSIRaster.


ENVI uses the RGB-to-HSI transform described in the following reference:

Gonzalez, R.C., and R.E. Woods. "Color Image Processing." In Digital Image Processing, Third Edition. Pearson Prentice Hall, 2008.

ENVI performs some additional processing steps that you should be aware of:

  • It normalizes the original raster pixel values (r) as follows:

  • For better visual display, it scales the hue values by 360 so they range from 0 to 1.


Hue represents the dominant color that humans see in an object. It is measured as an angle on a color wheel, where red is 0°, green is 120°, and blue is 240°.


The saturation of a color is a measure of its purity or greyness. The purest colors have values close to 1.0, and greyer colors have values close to 0.0.


Intensity is commonly referred to as brightness. It is the average of the RGB values:


; Start the application
e = ENVI()
; Open an input file
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
; Create a spectral subset with the correct
; band order for RGB
subset = raster.Subset(BANDS=[2,1,0])
; Transform RGB to HSI
hsiRaster = ENVIRGBToHSIRaster(subset)
; Display the result
View = e.GetView()
Layer = View.CreateLayer(hsiRaster)


ENVIRaster = ENVIRGBToHSIRaster(Input_Raster, ERROR=variable)

Return Value

This routine returns a reference to an ENVIRaster that has been transformed from a red/green/blue (RGB) to hue/saturation/intensity (HSI) color space. For better visual display, ENVI scales the hue values by 360 so they range from 0 to 1.



Specify the input ENVIRaster. It must have three bands in the following order: Red, Green, and Blue.

If your original raster has more than three bands, or if it has red/green/blue bands that are not in the correct order, use ENVISubsetRaster to create a spectral subset for input to ENVIRGBToHSIRaster. Use the BANDS keyword to define a three-band subset, using zero-based band numbers. In the code example above, the original image (qb_boulder_msi) has four bands:



band number













To create an RGB raster with the correct band order, the example defines the BANDS array in ENVISubsetRaster as [2, 1, 0] since:

  • The zero-based band number for Red is 2
  • The zero-based band number for Green is 1
  • The zero-based band number for Blue is 0


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




ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.


Specify a string that identifies the raster.

Version History

ENVI 5.3.2


ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

API Version


See Also

ENVIRaster, RGBToHSIRaster Task