MATLAB: MATLAB documentation claims that the output of rgb2ycbcr MATLAB inbuilt command is in the range [0, 1] for RGB input image of class double. However, its output is not in the mentioned range. Why

rgb2ycbcr

I am using the following commands:- A = imread('Lena_color_512.bmp'); Ad = double(A); Aybr = rgb2ycbcr(Ad); Intensity values of the 3-D matrix Aybr are not in the range [16/255, 235/255]. Can anybody tell the possible reason for this or is there an implementation error?

Best Answer

The Matlab help makes a number of assumptions it seems when working with image processing. One of these being that if an image is of type 'double' (or 'single'), that its values will always be between 0 and 1. So you cannot just cast your image to double, you would have to normalise it too, otherwise it behaves just as if it were uint8 or whatever data type the actual range of the data corresponds to.