資源簡介
本代碼適用于圖像處理的學(xué)習(xí),對數(shù)字圖像進行DFT,DHT,DCT等變換,比較各自的特點。
代碼片段和文件信息
I?=?imread(‘lena512.bmp‘);
I=double(I);
pt=0.95;
%%?DFT
tic;
F=fftshift(fft2(I));
clock1=toc;
m_fft=10*log(1+abs(F));
Threshold=findthreshold(m_fftpt);
F_re=F.*(m_fft>Threshold);
tic;
I_re_dft?=?ifft2(ifftshift(F_re));
clock2=toc;
figure
subplot(131);
imshow(I?[])?title(‘原圖‘);
subplot(132);
imshow(m_fft?[])?title(‘DFT幅度譜‘);
subplot(133);
imshow(I_re_dft?[])?title(‘DFT復(fù)原圖‘);
PSNR=PSNR_value(II_re_dft);
str=[‘DFT變換??PSNR=‘num2str(PSNR)];
suptitle(str);
fprintf(‘PSNR_DFT=%0.3f?dB\n‘?PSNR);?
fprintf(‘?DFT耗時?%0.3f?s\n‘?clock2+clock1);
%%?DCT
tic;
C=dct2(I);
clock1=toc;?
m_dct=10*log(1+abs(C));
Threshold=findthreshold(m_dctpt);
C_re=C.*(m_dct>Threshold);
tic;?
I_re_dct=idct2(C_re);
clock2=toc;
figure
subplot(131);
imshow(I?[])?title(‘原圖‘);
subplot(132);
imshow(m_dct?[
- 上一篇:單層感知器Matlab代碼-異或運算
- 下一篇:wavelet.m
評論
共有 條評論