function [ Y, chroma ] = RGB_to_YCbCr( frame_in )
    
     Y = 0.299 * double( frame_in(:,:,1) ) + 0.587 * double( frame_in(:,:,2) ) + 0.114 * double( frame_in(:,:,3) );
     Cb = conv2( double( frame_in(:,:,3) ) - Y , 1/4*ones(2,2) ,'same' );     
     Cr = conv2( double( frame_in(:,:,1) ) - Y , 1/4*ones(2,2) ,'same' );  
     Cb = Cb(1:2:end,1:2:end);     
     Cr = Cr(1:2:end,1:2:end);
     
     chroma = zeros(size(Cb,1),size(Cb,2),2);
     chroma(:,:,1) = Cb;
     chroma(:,:,2) = Cr;

end

