IHS

RGB to IHS conversion


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Examples :: Algorithm :: References :: Related

Back to top

Description


Converts red, green, and blue (RGB) image channels to intensity, hue, and saturation (IHS) image channels. The IHS program is the inverse of the RGB program. The Intensity-Hue-Saturation transformation is used by the FUSE and FUSEPCT functions to perform data fusion.
Back to top

Parameters


Name Type Caption Length Value range
FILE * String Input file name 1 - 192  
DBIC * Integer Input RGB channels 3 - 3  
DBOC * Integer Output IHS channels 3 - 3  
DBIW Integer Input window 0 - 4 Xoffset, Yoffset, Xsize, Ysize
IHSMODEL String IHS Model 0 - 8 CYLINDER | HEXCONE
Default: CYLINDER
MONITOR String Monitor mode 0 - 3 ON, OFF
Default: ON

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the PCIDSK image file containing the Red-Green-Blue input and Intensity-Hue-Saturation output image channels.

DBIC

Specifies the three input image channels to be interpreted as the Red, Green, and Blue components of a color image.

If the output channels (DBOC) are specified as all 8-bit channels, the input channels must all be 8-bit. If the output channels are 16- or 32-bit, the input channels may be of any type. See the Details section for more information on channel types.

DBOC

Specifies the three output channels to be interpreted as the intensity, hue, and saturation components of a color image.

Output channels must be either all 8-bit or all 16- or 32-bit; see the Details section for more information on channel types. Output channels may be the same as the input channels; existing data will be overwritten.

DBIW

Specifies the rectangular window (Xoffset, Yoffset, Xsize, Ysize) that is read from the input channels. If this parameter is not specified, the entire image 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.

IHSMODEL

Specifies the type of IHS color model to use.

Supported color models are:

See the Details section for more information about these IHS models.

MONITOR

The program progress can be monitored by printing the percentage of processing completed. A system parameter, MONITOR, controls this activity.

Available options are:

Back to top

Details

IHS converts red, green, and blue image channels to intensity, hue, and saturation image channels. This is useful for enhancing and controlling the output colors for the given set of input red/green/blue imagery.

IHS is used by the FUSE and FUSEPCT functions to perform data fusion of color imagery with a black-and-white image.

The IHSMODEL parameter specifies the IHS model (HEXCONE or CYLINDER) that was originally used to transform RGB values to IHS values. CYLINDER was the original method used by the IHS and RGB functions in older PCI software releases (version 6.0.1 and earlier). The Hexcone model is used by many commercial Image Processing software applications. One model may produce more visually pleasing results than the other, depending on the circumstances. The Hexcone model runs about 15% faster than the Cylinder model.

Input channels may be used as output channels, in which case the original input image is overwritten by the output image. Duplicate channel numbers may be specified for input channels, but NOT for output channels.

Only the following configurations of input and output channel types are allowed:

 Output channels (DBOC)      Input channels (DBIC)

 Scaled results:  8-bit      8-bit
 Exact  results:  16/32-bit  any type

When all input and output channels are 8-bit, the output data are linearly scaled between 0 and 255. When the three output channels are any combination of 16-bit signed, 16-bit unsigned or 32-bit real, any type of input channel is allowed and the output values are not scaled. If the output channels are 16-bit, unscaled values are truncated to integer values.

The RGB function can be used to convert intensity, hue, and saturation channels output by IHS back to red, green, and blue channels.

Back to top

Examples

The following example uses the IHS and RGB functions to perform data fusion of the ERS-1 radar image on channel 11 with the color RGB TM image on channels 3, 2, and 1 of irvine.pix. The result is a new color ERS-1 image, where the intensity comes from the original ERS-1 image and the color (hue and saturation) come from the original RGB image.

Note: This example overwrites data on channels 1, 2, 3, 6, 7, 8, and 9 of the irvine.pix file.

For best results, input images should be enhanced and scaled before running IHS. The 16-bit ERS-1 image on channel 11 is scaled to an 8-bit image and saved on channel 8, as follows:

EASI>FILI	=	"irvine.pix"	! input image
EASI>FILO	=	"irvine.pix"	! output image same as input
EASI>DBIC	=	11	! 16-bit radar image
EASI>DBOC	=	6	! 8-bit channel
EASI>DBIW	=	! entire image
EASI>DBOW	=	! entire image
EASI>INRANGE	=	0,1535
EASI>TRIM	=
EASI>OUTRANGE	=		! default range (0,255)
EASI>SFUNCT	=	"LIN"	! automatic linear scaling

EASI>RUN SCALE

The 8-bit RGB image on channels 3, 2, and 1 are enhanced using the lookup tables stored in segments 4, 3, and 2, as follows:

EASI>FILE	=	"irvine.pix"
EASI>DBIC	=	3,2,1	! use input image channels 3,2,1
EASI>DBLUT	=	4,3,2	! using LUT segments 4,3,2
EASI>DBOC	=	3,2,1	! overwrite input channels
EASI>MASK	=		! entire image

EASI>RUN LUT

An IHS transformation is performed on the enhanced color image, using the Cylinder color model, and saved in channels 7, 8, and 9:

EASI>FILE	=	"irvine.pix"
EASI>DBIC	=	3,2,1	! use input image channels 3,2,1
EASI>DBOC	=	7,8,9	! output channels for IHS image
EASI>DBIW	=		! entire image
EASI>IHSMODEL	=	"CYLINDER"

EASI>RUN IHS

An RGB transformation is performed using the 8-bit scaled ERS-1image image as the intensity (channel 6), and the hue and saturation images (channels 8 and 9) derived from the original color TM image. The new RGB color image is saved in channels 7, 8, and 9, as follows:

EASI>FILE	=	"irvine.pix"
EASI>DBIC	=	6,8,9
EASI>DBIC	=	7,8,9
EASI>DBIW	=	

EASI>RUN RGB
Note: The FUSE procedure could have been used to perform data fusion, instead of running IHS and RGB, as follows:
EASI>FILI	=	"irvine.pix"
EASI>DBRGB	=	3,2,1
EASI>FILO	=	"irvine.pix"
EASI>DBINT	=	6
EASI>DBOC	=	7,8,9
EASI>RESAMPLE	=
EASI>IHSMODEL	=	"CYLINDER"

EASI>RUN FUSE

Transfer the new color image on channels 7, 8, and 9 to the display using Focus tools.

Back to top

Algorithm

The equations used to convert Red, Green, and Blue color values to Intensity, Hue, and Saturation color values for both the Cylinder and the Hexcone IHS models are provided below.

Cylinder

The following algorithm is used to convert RGB to IHS values using the cylinder color model.

 R = Red, G = Green, B = Blue
 I = Intensity, H = Hue, S = Saturation

 K2 = 1 / sqrt(2)
 K3 = 1 / sqrt(3)
 K6 = 1 / sqrt(6)
 PI is the constant PI (3.14159)
 RadToDeg = 180 / PI (factor to convert radians to degrees)

 B1 = K6 * (2*B - R - G)
 X1 = K2 * (G - R)

 I = K3 * (R + G + B)

 If (B1 = 0) then
     If (R <= G) H = 90
     If (G < R)  H = 270

 If (B1 <> 0) then
     H = RadToDeg * atan(X1 / B1) 
     If (G > R and H < 0) H = H + 180
     If (G < R and H > 0) H = H + 180
     If (G = R and R > B) H = 180

 If (H < 0) H = H + 360
 If (H >= 360) H = H - 360
 
 S = sqrt(B1 * B1 + X1 * X1)

If the output channels are all 8-bit, the Intensity, Hue, and Saturation values are scaled between 0 and 255:

 I = I * (255 / 442)
 H = H * (255 / 360)
 S = S * (255 / 208.2066)

For more information on the above algorithm, please see Kruse, F.A. and G.L. Raines, and Bonham-Carter, Graeme F. in the References section.

Hexcone

The following algorithm is used to convert RGB to IHS values using the single-hexcone color model.

 R = Red, G = Green, B = Blue
 I = Intensity, H = Hue, S = Saturation

 Max = Maximum(R,G,B)
 Min = Minimum(R,G,B)
 Delta = Max - Min

 I = Max

 If (Max <> 0) S = Delta / Max
 If (Max = 0)  S = 0

 If (S = 0) H = 0                       (Hue is undefined)

 If (R = Max) H = (G - B) / Delta       (between yellow and magenta)
 If (G = Max) H = 2 + (B - R) / Delta   (between cyan and yellow)
 If (B = Max) H = 4 + (R - G) / Delta   (between magenta and cyan)
 H = H * 60                             (convert Hue to degrees)
 If (H < 0) H = H + 360                 (Hue must be positive)
 If (H >= 360) H = H - 360              (Hue must be less than 360)

If the output channels are all 8-bit, the Hue and Saturation values are scaled between 0 and 255:

 H = H * (255 / 360)
 S = S * 255

For more information on the above algorithm, please see Foley, J.D., A. van Dam, S.K. Feiner and J.F. Hughes in the References section.

Back to top

References

Kruse, F.A. and G.L. Raines, (1984). A Technique For Enhancing Digital Color Images by Contrast Stretching in Munsell Color Space. In Proceedings of the International Symposium on Remote Sensing of Environment, 3rd Thematic Conference, Environmental Research Institute of Michigan, Colorado Springs, Colorado, pp. 755-773.

Bonham-Carter, Graeme F., (1994). Geographic Information Systems for Geoscientists: Modelling with GIS. Computer Methods in the Geosciences, Volume 13, published by Pergamon (Elsevier Science Ltd), pp. 120-125.

Foley, J.D., A. van Dam, S.K. Feiner and J.F. Hughes, (1990). Computer Graphics: Principles and Practice (second edition). Addison-Wesley Publishing Company.

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