Following this exact question
where he is performing chroma downscaling from 4:4:4 to 4:2:0, I wanna dowscale from 4:4:4 to 4:1:1. Im not sure how to do that?
YUV = rgb2ycbcr(RGB);
Y = YUV(:, :, 1);
U = YUV(:, :, 2);
V = YUV(:, :, 3);
Performing downscaling
U = double(YUV(:, :, 2))
V = double(YUV(:, :, 3))
newU = ??
newV =??
Can anyone please help me?
Thanks in advance.
In YUV 4:1:1, the chroma channels are down-sampled by a factor of 1/4 in the horizontal axis.
Using imresize, the solution is simple:
Notes:
imresize
applies cubic interpolation with antialiasing enabled.Most real-world implementations uses simpler interpolation methods, like linear interpolation without antialiasing.
Chroma subsampling illustrations:
[https://robbeekmans.net/euc/vmware-horizon-7-4-blast-gets-necessary-update-support-chroma-subsampling-444-h-264/]
Another illustration:
[https://academickids.com/encyclopedia/index.php/YUV_4:2:0]
Implementing without using
imresize
:In case you want the same result as
imresize
(bilinear without Antialiasing):The following code is equivalent:
You may also use the average of every 4 elements (better if reducing noise is important):
Note:
I prefer the term "down-sampling" over "sub-sampling".
Sub-sampling by 1/4 means skipping - sample every 4 element, and ignore the other 3.
Historically, in analog (or mixed analog/digital) video systems, the conversion to 4:1:1 most likely performed by analog sub-sampling.
In digital systems, when you already have the 4:4:4 information, it's better to average samples than skip samples.
I think the term "down-sampling" is more adequate (but "sub-sampling" is the commonly used term).