Use READRGB and READBMP to read images into matrices. This example uses the image below.
dog.bmp
1. Use READRGB to read a color image.
This matrix contains an RGB representation of the image.
2. Use READBMP to read the same a image file.
This matrix contains a grayscale representation of the image, even though this is originally a color image.
3. Compare the sizes of the two matrices.
M1 is three times bigger than M2. M1 is a packed image matrix, containing three matrices representing the red, green, and blue values of the image. M2 represents the gray levels of the image.
4. Use WRITERGB and WRITEBMP to write out the packed image matrix M1.
5. Compare the two images.
(dogRGB.bmp)
(dogBMP.bmp)
WRITERGB creates an RGB image. WRITEBMP creates three images that represent the levels of red, green, and blue of the image, respectively.
6. Calculate the width of the original image, based on the packed image matrix.
7. Create three separate matrices for the red, green and blue values of the image.
8. Use WRITEBMP to write the matrices to files and view the results.
(rDog.bmp)
(gDog.bmp)
(bDog.bmp)
The red, green, and blue components are viewed as grayscale images.
9. Use the augment function to create a packed image matrix and manipulate the blue values.
10. Compare the two images.
(dogRGB2.bmp)
(dogBMP2.bmp)
WRITERGB writes the RGB image using the red, green, and blue values combined together. WRITEBMP writes a file three times wider, with the red levels, green levels, and blue levels represented as a grayscale image.