function YCbCr_image = EQA3YM_RGB_to_YCbCr( RGB_image )
% Converts image from RGB to YCbCr
%  please decompose your 3D RGB array to 2D arrays, in accordance with the color channels 
%  create the luminosity array (Y) and the two chrominance arrays (Cb, Cr) with respect to these formulas
%  shift the new values with -128 (the reason: the range of the DCT-components will be narrower this way)

offset = [ 0 128 128 ];
T      = [ 0.2990  0.5870  0.1140
          -0.1687  0.3313  0.5000
           0.5000 -0.4187  0.0813];

% Credit goes to Botos Csaba who showed that trick to me:
YCbCr_image = bsxfun(@plus, reshape(double(RGB_image),[],3)*T', offset); 
YCbCr_image = reshape(YCbCr_image,size(RGB_image));

end

