Functions > Image Processing > Image Color Tools > Converting Images: Grayscale and Color
Converting Images: Grayscale and Color
The following functions convert between grayscale and color in images. One function takes an RGB color image and converts it to a grayscale image, and the other does the reverse. These functions are useful for converting one type of image to another, and also for false color imaging.
gray_to_rgb(gray, colormap)—Returns single color vector or packed grayscale matrix gray converted to a packed color matrix using color palette matrix colormap.
rgb_to_gray(RGB)—Returns packed RGB color matrix RGB converted to grayscale.
gray, RGB are image matrices or vectors.
colormap is a four-column matrix specifying grayscale intensity in the first column, and RGB values in the second through fourth columns respectively. First column values must be real numbers between 0 and 255.
Alternatively, the functions described above can take three arguments, for example (R,G,B), where R, G, and B are scalars or matrices.
Was this helpful?