天天看點

matlab ftt圖像壓縮,求助 fft圖像壓縮程式問題

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

在做畢設

參照數字圖像壓縮技術及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.

這個錯誤是怎麼回事?怎麼解決呢?

求大神解答