Image Processing Toolkit User Guide > Reference A–I > IS_GRAY_CMAP Function (PV-WAVE Extreme Advantage)
  

IS_GRAY_CMAP Function (PV-WAVE Extreme Advantage)
Determines if a colormap is grayscale.
Usage
result = IS_GRAY_CMAP(colormap)
Input Parameters
colormap—A 3-by-n_colors array containing the colormap, where n_colors is the number of colors in the colormap.
Returned Value
result—A value indicating if the colormap is grayscale as follows:
*1—Grayscale colormap
*0—Colormap not grayscale
Keywords
Linear—If set, determines if the colormap is monotonically increasing.
Discussion
In a grayscale colormap, the red, green, and blue components are equal to each other for each element in the colormap. Therefore, to test for a grayscale colormap, the following equation is true:
red(i) EQ blue(i) EQ green(i),   for 0 i < n_colors
where n_colors is the number of colors in the colormap.
A grayscale colormap is said to be linear if the grayscale value is monotonically increasing. To determine linearity for a grayscale colormap, it is sufficient to test only the red component as follows:
red(i – 1) < red(i),   for 1 i < n_colors
where n_colors is the number of colors in the colormap.
Example
; Get the current colormap.
TVLCT, r, g, b, /Get
; Put it into a colormap array.
cmap = BYTARR(3, N_ELEMENTS(r))
cmap(0, *) = r
cmap(1, *) = g
cmap(2, *) = b
result = IS_GRAY_CMAP(cmap, /Linear)
; Check to see if it is linear grayscale.
IF result EQ 1 THEN PRINT, 'Colormap is ' + $
'linear grayscale.' $ &
ELSE PRINT, 'Colormap is not linear grayscale.'
See Also
IPLINEAR_GRAY

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.