Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying Y Cb and Cr components in Matlab

Tags:

matlab

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?

like image 272
Avinash Pawar Avatar asked Jan 18 '26 16:01

Avinash Pawar


2 Answers

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

enter image description here

like image 109
Daniel Avatar answered Jan 21 '26 09:01

Daniel


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:

enter image description here

like image 21
Benoit_11 Avatar answered Jan 21 '26 08:01

Benoit_11



Donate For Us

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