该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
在做毕设
参照数字图像压缩技术及matlab实现这本书的程序。
% 装入256×256的图像
initialImage=imread('nanmen.jpg');InitialImage=rgb2gray(initialImage);
% 对图像进行归一化
InitialImage=double(InitialImage)/255;
%显示原始图像
figure(1);imshow(InitialImage);
DCTCoe=blkproc(InitialImage,[16 16],'fft2(x)');
%将系数矩阵重新排列
CoeVar=im2col(DCTCoe,[16 16],'distinct');Coe=CoeVar;
%将系数矩阵排序
[Y,Ind]=sort(CoeVar);%[m,n]=size(CoeVar);Snum=192;
%按压缩比保留高位次系数
for i=1:n
Coe(Ind(1:Snum),i)=0;
end
%重新排列系数矩阵
B2=col2im(Coe,[16 16],[256 256],'distinct');
%对子图像进行FFT反变换获得各个子图像的恢复图像
I2=blkproc(B2,[16 16],'ifft2(x)');
%显示压缩后的图像
figure(2);imshow(I2);
%计算压缩后的图像
error=InitialImage.^2-I2.^2;
MSE=sum(error(:))/prod(size(I2))
Warning: Image is too big to fit on screen; displaying at 67%> In imuitools\private\initSize at 86 In imshow at 201??? Error using ==> col2imThe column size of b not consistent with BLK2COL size.
>> B2=col2im(Coe,[16 16],[256 256],'distinct');??? Error using ==> col2imThe column size of b not consistent with BLK2COL size.
这个错误是怎么回事?怎么解决呢?
求大神解答