%Chapter 8, Fig 8.1 %Eric Dubois, updated 2018-12-14 %Figure to display a color image and its RGB components as color images and %as gray-scale images. %Two different ways of displaying an image are shown here %Data file should be placed in a data directory on the MATLAB path. clear all; close all; %Input the original color image RGB = imread('05.tif'); figure; imshow(RGB) axis off set(gcf,'Color',[1 1 1]); %Create three color images with one of the R, G, B components R_comp = zeros(size(RGB),'uint8'); R_comp(:,:,1) = RGB(:,:,1); figure; imshow(R_comp) axis off set(gcf,'Color',[1 1 1]); G_comp = zeros(size(RGB),'uint8'); G_comp(:,:,2) = RGB(:,:,2); figure; imshow(G_comp) axis off set(gcf,'Color',[1 1 1]); B_comp = zeros(size(RGB),'uint8'); B_comp(:,:,3) = RGB(:,:,3); figure; imshow(B_comp) axis off set(gcf,'Color',[1 1 1]); %Create three scalar component images, displayed as gray-scale images. R_comp_scalar = RGB(:,:,1); figure; imshow(R_comp_scalar) axis off set(gcf,'Color',[1 1 1]); G_comp_scalar = RGB(:,:,2); figure; imshow(G_comp_scalar) axis off set(gcf,'Color',[1 1 1]); B_comp_scalar = RGB(:,:,3); figure; imshow(B_comp_scalar) axis off set(gcf,'Color',[1 1 1]);