Domanda

I am setting Y, Cb and Cr to zero and converting it back to RGB using matlab. What i don't understand is that why am i getting Red and Blue component as zero in RGB color space while the green component has value 132?

EDIT: (code from comment):

I1 = imread('img.jpg'); 
img = rgb2ycbcr(I1); 
lumin = img; 
lumin(:,:,1) =0; 
lumin(:,:,2) =0; 
lumin(:,:,3)=0; 
figure,imshow(lumin); 
rgn = ycbcr2rgb(lumin); 
figure,imshow(rgn);
È stato utile?

Soluzione

Conversion formulas between RGB and YCbCr involve offsets. So even if it is all zeros in one domain you will not get all zeros in the other domain. If you directly use the formula to convert an all zero YCbCr domain matrix to RGB you would get positive green values and negative red and blue values. These negative values are usually thresholded to 0 which is what you are seeing.

The wikipedia page http://en.wikipedia.org/wiki/YCbCr and MATLAB Color Space Conversion block reference page at http://www.mathworks.com/help/vision/ref/colorspaceconversion.html shows the formulas used.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top