Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

DGM
DGM el 8 de Mayo de 2023
Editada: DGM el 8 de Mayo de 2023
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 comentario
Sunil
Sunil el 8 de Mayo de 2023
@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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by