我的功能读取图像 - >转换为ycbcrI - > DCT - >量化 - >使用zigzag的最终图像。我的上一个操作有问题 - 将数据保存到图像。我想使用Out变量保存为图像。怎么做 ? imwrite dosen&work :(
[Img,map] = imread('test.jpg');
T = [16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];
figure(1)
imshow(Img);
title('Orginal img');
Img2 = rgb2ycbcr(Img);
[W,S,n] = size(Img2);
figure(2)
imshow(Img2);
title('After rgb2ycbcr');
Y1 = Img2(1:1:W,1:1:S,1);
Cb1 = Img2(1:1:W,1:1:S,2);
Cr1 = Img2(1:1:W,1:1:S,3);
l=3;
Y1 = wextend('2D','zpd',Y1,l,['d','r']);
Cb1 = wextend('2D','zpd',Cb1,l,['d','r']);
Cr1 = wextend('2D','zpd',Cr1,l,['d','r']);
fun = @dct2
Y2 = blkproc(Y1,[8 8],fun);
Cb2 = blkproc(Cb1,[8 8],fun);
Cr2 = blkproc(Cr1,[8 8],fun);
fun2 = @(block_struct) round(block_struct./T);
Y2 = blkproc(Y2,[8 8],fun2);
Cb2 = blkproc(Cb2,[8 8],fun2);
Cr2 = blkproc(Cr2,[8 8],fun2);
YCbCr = Y2+Cb2+Cr2;
Out = zigzag(YCbCr);