I have a RGB image of dimensions 640*480. I have converted it to Y Cb Cr image by using the Matlab command Rgbtoycbcr but i want to display the Y Cb Cr components separately as Figures. How do i do it?
This is an extension of Benoit_11's code. Instead of displaying the values of each channel as a greyscale image, this code fills the other channels with a constant value of 50%. This way the influence of each channel to the final picture is easier to observe. Especially the importance of the Y channel is obvious.
RGB = imread('board.tif');
YCBCR = rgb2ycbcr(RGB);
figure;
lb={'Y','Cb','Cr'};
for channel=1:3
subplot(1,3,channel)
YCBCR_C=YCBCR;
YCBCR_C(:,:,setdiff(1:3,channel))=intmax(class(YCBCR_C))/2;
imshow(ycbcr2rgb(YCBCR_C))
title([lb{channel} ' component'],'FontSize',18);
end

You can display each component as you would do for the red, green or blue channels of a RGB image indexing the 3rd dimension of your image.
Simple example:
RGB = imread('board.tif');
YCBCR = rgb2ycbcr(RGB);
figure;
subplot(1,3,1)
imshow(YCBCR(:,:,1))
title('Y component','FontSize',18);
subplot(1,3,2)
imshow(YCBCR(:,:,2))
title('Cb component','FontSize',18);
subplot(1,3,3)
imshow(YCBCR(:,:,3))
title('Cr component','FontSize',18);
Output:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With