Let's start with the very basics. Importing a color image and accessing its pixels is pretty much the same process as in the case of grayscale images. We can see it using the color version of the image used in Chapter 1, Basic Image Manipulations. To open both the color version and the grayscale version, we will use imread
twice:
>> img_gray = imread('my_image.bmp'); >> img_color = imread('my_image_color.bmp');
Examining the workspace will reveal the aforementioned difference between grayscale and color images, which is the dimensionality. As we can see in the following screenshot, the grayscale version is 485-by-686 and the color version is 485-by-686-by-3.
To display both the grayscale and color images, as well as the three color channels of the latter separately on the same figure, we will type in:
>> subplot(2,3,1),imshow(img_gray);title('Grayscale image') >> subplot(2,3,2),imshow(img_color);title('Color image') >> subplot(2,3...