Downsample chrominance components of images using matlab -


i want decompose image y,cb,cr components , perform downsampling in ycbcr domain form 4:2:2 format.

code decomposition of image ycbcr:

img=imread('flowers.tif'); figure(1), imshow(img);title('original image'); y=0.299*img(:,:,1)+0.587*img(:,:,2)+0.114*img(:,:,3); cb=-0.1687*img(:,:,1)-0.3313*img(:,:,2)+0.5*img(:,:,3)+128; cr=0.5*img(:,:,1)-0.4187*img(:,:,2)-0.0813*img(:,:,3)+128;  %print y, cb, cr components  figure(2), subplot (1,3,1), imshow(y), title('y,cb,cr components'), subplot(1,3,2), imshow(cb),subplot(1,3,3), imshow(cr); 

now need perform down-sampling?

if downsampling mean chroma subsampling 4:4:4 4:2:2, 1 way (and keep original size of channel) manually overwrite every other pixel previous value:

cb(:, 2:2:end) = cb(:, 1:2:end-1); cr(:, 2:2:end) = cr(:, 1:2:end-1); 

if want remove half of columns, use:

cb(:, 2:2:end) = []; cr(:, 2:2:end) = []; 

also in matlab don't need write own function ycbcr conversion. instead can use rgb2ycbcr().


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -