The IDLgrPalette::NearestColor function method returns the index of the palette color that best matches the given RGB values, using a simple squared-distance formula.

Syntax


Result = Obj->[IDLgrPalette::]NearestColor(Red, Green, Blue)

Return Value


Returns the index of the color in the palette that best matches the given RGB values. If Red, Green, and Blue are scalars then the result is a long integer. If Red, Green, and Blue are arrays then the result is a byte array.

Arguments


Red

A scalar or array giving the red values of the colors that should be matched. These values should be within the range of 0 to 255. For arrays the Red, Green, and Blue arguments should have the same number of elements.

Green

A scalar or array giving the green values of the colors that should be matched. These values should be within the range of 0 to 255. For arrays the Red, Green, and Blue arguments should have the same number of elements.

Blue

A scalar or array giving the blue values of the colors that should be matched. These values should be within the range of 0 to 255. For arrays the Red, Green, and Blue arguments should have the same number of elements.

Keywords


None

Version History


5.0

Introduced

8.5

Allow arguments to be arrays.