필터 지우기
필터 지우기

While Downsampling 4:4:4 YCbCr image to 4:2:0 using imresize inbuilt function should we scale it by 0.5 or 0.25

조회 수: 4 (최근 30일)
I have converted RGB image into its YCbCr equivalent i.e. 4:4:4. And separated its Y, Cb and Cr components.
Now i need to downsample this 4:4:4 sample into 4:2:0 sample. For this i am using imresize inbuilt command.
Y component will be as it is in 4:2:0. The doubt i have is for Cb and Cr chroma components should i scale each component by 0.5 or 0.25.
Code:
%Load Image
RGB = imread('dbz.jpg');
%convert image to YCbCr color space
YCBCR = rgb2ycbcr(RGB);
%Extract Y and Cb, Cr components from the converted image it is in 4:4:4
Y=YCBCR(:,:,1);
Cb=YCBCR(:,:,2);
Cr=YCBCR(:,:,3);
Next which below code should i use 0.5 or 0.25 ?
%4:2:0 conversion of YCbCr using inbuilt command with bilinear
Cb_auto = imresize(Cb, 0.5, 'bilinear', 'Antialiasing', false);
Cr_auto = imresize(Cr, 0.5, 'bilinear', 'Antialiasing', false);
or
%4:2:0 conversion of YCbCr using inbuilt command with bilinear
Cb_auto = imresize(Cb, 0.25, 'bilinear', 'Antialiasing', false);
Cr_auto = imresize(Cr, 0.25, 'bilinear', 'Antialiasing', false);
Why i have this doubt is that i read like 4:2:2 samples chroma at 1/2th the luma samples.
Whereas 4:2:0 samples chroma at 1/4th the luma samples.
Help is appreciated!

채택된 답변

DGM
DGM 2023년 5월 8일
편집: DGM 2023년 5월 8일
Let me preface this answer by saying that I am not familiar with the conventions used for various file encodings. How exactly the image data gets downsampled (the method of interpolation, the use of antialiasing) is something I can't comment on.
That said, 4:2:2 reduces the amount of chroma information by half by reducing resolution by 0.5 in one dimension. Using 4:2:0 reduces the amount of chroma information by a quarter by reducing resolution by 0.5 in both dimensions. In other words, when you resize the chroma channels by 0.5, you're reducing the amount of pixels to 0.5^2 = 0.25.
  댓글 수: 1
Sunil
Sunil 2023년 5월 8일
@DGM yes understood it now, by your explanation, Thank you!
So, i have to use this,
%4:2:0 conversion of YCbCr using inbuilt command with bilinear
Cb_auto = imresize(Cb, 0.5, 'bilinear', 'Antialiasing', false);
Cr_auto = imresize(Cr, 0.5, 'bilinear', 'Antialiasing', false);
The matrix i get after scaling Cb component by 0.5
Original image - 360x640 = 230,400 pixels
0.5 Scaled image - 180x320 = 57,600 pixels
230,400 * 1/4 = 57,600 (i.e. 1/4th of original pixels)
Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by