The RGB values are converted to grayscale using the NTSC formula: 0.299 ∙ Red + 0.587 ∙ Green + 0.114 ∙ Blue. This formula closely represents the average person's relative perception of the brightness of red, green, and blue light.
3. Insert the two images to view the color difference.
(smallwar.gif)
(smallwar_rgb_gray.bmp)
gray_to_rgb
When converting a grayscale matrix to RGB, false colors are assigned to the intensity levels in the image.
1. Read in a grayscale image.
(bridge.bmp)
2. Define a data set that describes a rainbow spectrum colormap.
3. Use the spectrum colormap for converting the grayscale image to RGB.
(colorbridge.bmp)
gray_to_rgb does not use the built-in ORIGIN variable, which specifies the starting index of an array for other functions.