%Code that runs conversion of color image to YCbCr

%read in image filename
%inimage = input('Enter image file name with extension (like jennifer.bmp): ', 's');

%open image file
inimage = imread('bison-us1.png');

%display on screen the image
figure(1), imshow(inimage); title('Original Image');


%the command size returns the size of the matrix/image
%A semi-colon suppresses the screen output of the variable
%values, while the lack of semi-colon prints it to the screen


size(inimage)

U = rgb2ycbcr(inimage);
figure(1), imshow(inimage); title('RGB image');
figure(2), imshow(U); title('YCBCR Image');
size(U)

%Here pick off the 256x256 luminance part of the ycbcr image
Y = U(:,:,1);
figure(3), imshow(Y); title('Y part of Image');
size(Y)

%Here pick off the 256x256 Cb part of the ycbcr image
CB = U(:,:,2);
figure(4), imshow(CB); title('Cb part of Image');
size(CB)

%Here pick off the 256x256 Cr part of the ycbcr image
CR = U(:,:,3);
figure(5), imshow(CR); title('Cr part of Image');
size(CR)