MATLAB: Problem in ycbcr color space

color spaceimage processingImage Processing Toolboxycbcr

I am facing some problems in using the ycbcr color space. For a certain purpose this model is the most suitable. But conversion from RGB to ycbcr yields me some negatives values too… Please help. Why does this happen? Are there any ways to solve this?

Best Answer

My speculation would be that you started with a uint8() image, used double() on that, and asked to use rgb2ycbcr() on the result. That could result in negative values, as the datatype of what you ask to convert (uint8 or double) determines which range of values are expected (0 to 255, or 0.0 to 1.0).
Always remember: the result of applying double() to a uint8 image is not an image! If you want your image represented in double precision then use im2double() not just double()