Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 基于matlab的图像下采样色度分量_Image_Matlab_Image Processing - Fatal编程技术网

Image 基于matlab的图像下采样色度分量

Image 基于matlab的图像下采样色度分量,image,matlab,image-processing,Image,Matlab,Image Processing,我想将图像分解为Y、Cb、Cr分量,然后在YCbCr域中执行下采样,形成4:2:2格式 将图像分解为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; C

我想将图像分解为Y、Cb、Cr分量,然后在YCbCr域中执行下采样,形成4:2:2格式

将图像分解为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);

现在我需要做什么来执行下采样?

如果下采样具体指的是从4:4:4到4:2:2的色度二次采样,那么一种方法(并保持通道的原始大小)是手动用以前的值覆盖每一个像素:

Cb(:, 2:2:end) = Cb(:, 1:2:end-1);
Cr(:, 2:2:end) = Cr(:, 1:2:end-1);
如果只想删除一半的列,请使用:

Cb(:, 2:2:end) = [];
Cr(:, 2:2:end) = [];

同样,在Matlab中,您不需要为YCbCr转换编写自己的函数。相反,您可以使用
rgb2ycbcr()

我喜欢这个替换插值示例。有没有聪明的方法来做线性插值?在这种特殊情况下还是一般情况下?在色度子采样的情况下,线性插值做的不多。但是,如果您正在寻找类似的方法来进行单向线性插值,请在上面的示例中使用
Cb(:,2:2:end-1)=(Cb(:,1:2:end-3)+Cb(:,3:2:end-1))/2