1. Use the READRGB function to read in an RGB image.
2. Convert the image to grayscale, and then use the WRITEBMP function to save the image to a file.
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. Use the READ_IMAGE function to 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, and then use the WRITERGB function to save the image to a file..
(colorbridge.bmp)
gray_to_rgb does not use the built-in ORIGIN variable, which specifies the starting index of an array for other functions.