matlab结果如图
clear;
figure
f=imread('E:\PICTRUE\Fig0432(a)(square_original).tif');
subplot(131);imshow(f);title('ÔʼͼÏñ');
[M,N]=size(f);
[f,revertclass]=tofloat(f);
F=fft2(f);
sig=10;
H=lpfilter('gaussian',M,N,sig);
G=H.*F;
g=ifft2(G);
g=revertclass(g);
subplot(132);imshow(g);
PQ=paddedsize(size(f));
Fp=fft2(f,PQ(1),PQ(2));
Hp=lpfilter('gaussian',PQ(1),PQ(2),2*sig);
Gp=Hp.*Fp;
gp=ifft2(Gp);;
gpc=gp(1:size(f,1),1:size(f,2));
gpc=revertclass(gpc)
subplot(133);imshow(gpc);title('原图');
f=imread('E:\PICTRUE\Fig0432(a)(square_original).tif');
[M,N]=size(f);
[f,revertclass]=tofloat(f);
F=fft2(f);
sig=10;
H=lpfilter('gaussian',M,N,sig);
G=H.*F;
g=ifft2(G);
g=revertclass(g);
imshow(g)
PQ=paddedsize(size(f));
Fp=fft2(f,PQ(1),PQ(2));
Hp=lpfilter('gaussian',PQ(1),PQ(2),2*sig);
Gp=Hp.*Fp;
gp=ifft2(Gp);
gpc=gp(1:size(f,1),1:size(f,2));
gpc=revertclass(gpc);
imshow(gp)
matlab结果如图
程序如下
f=imread('E:\PICTRUE\Fig0438(a)(bld_600by600).tif');
f=tofloat(f);
F=fft2(f);
S=fftshift(log(1+abs(F)));
imshow(S,[ ])
h=fspecial('sobel')
freqz2(h)
PQ=paddedsize(size(f));
H=freqz2(h,PQ(1),PQ(2));
H1=ifftshift(H);
imshow(abs(H),[ ])
figure,imshow(abs(H1),[ ])
gs=imfilter(f,h);
gf=dftfilt(f,H1);
imshow(gs,[ ])
figure,imshow(gf,[ ])
figure,imshow(abs(gs),[ ])
figure,imshow(abs(gf),[ ])
figure,imshow(abs(gs)>0.2*abs(max(gs(:))))
figure,imshow(abs(gf)>0.*abs(max(gf(:))))
matlab结果如图
程序如下
[U,V]=dftuv(8,5);
DSQ=U.^2+V.^2
fftshift(DSQ)
matlab结果如下图
程序如下
clc;
clear;
f=imread('E:\PICTRUE\Fig0441(a)(characters_test_pattern).tif');
[f,revertclass]=tofloat(f);
PQ=paddedsize(size(f));
[U,V]=dftuv(PQ(1),PQ(2));
D=hypot(U,V);
D0=0.05*PQ(2);
F=fft2(f,PQ(1),PQ(2));
H=exp(-(D.^2)/(2*(D0^2)));
g=dftfilt(f,H);
g=revertclass(g);
figure
subplot(221);imshow(f);title('');
subplot(222);imshow(fftshift(H));title(');
subplot(223);imshow(log(1+abs(fftshift(F))),[]);title('×');
subplot(224);imshow(g);title('');
matlab结果如图
程序如下
Hftshift(lpfilter('gaussian',500,500,50))mesh(doble(H(1:10:500,1:10:500)));
axis tight
colormap([0 0 0])
axis offw(-25,30)
view(-25,0)
matlab结果如图
程序如下
H=fftshift(hpfilter('gaussian',500,500,50));
mesh(double(H(1:10:500,1:10:500)));
axis tight
colormap([0 0 0])
axis off
figure,imshow(H,[ ])
H=fftshift(hpfilter('ideal',500,500,50));
mesh(double(H(1:10:500,1:10:500)));
axis tight
colormap([0 0 0])
axis off
figure,imshow(H,[ ])
matlab结果如图
程序如下
f=imread('E:\PICTRUE\Fig0441(a)(characters_test_pattern).tif');
PQ=paddedsize(size(f));
D0=0.05*PQ(1);
imshow(f);title('');
H=hpfilter('gaussian',PQ(1),PQ(2),D0);
g=dftfilt(f,H);
figure,imshow(g)
matlab结果如图
程序如下
I1=imread('E:\PICTRUE\Fig0459(a)(orig_chest_xray).tif');
[len,wed]=size(I1);
g=fft2(I1);
g=fftshift(g);
[M,N]=size(g);
m=fix(M/2);
n=fix(N/2);
D0=40;
n1=2
for i=1:M
for j=1:N
D=sqrt((i-m)^2+(j-n)^2);
H1=1-exp((-1)*(D^2/(2*D0^2)));
H2=0.5+0.75*H1;
s1(i,j)=H1*g(i,j);
s2(i,j)=H2*g(i,j);
end
end
I2=im2uint8(real(ifft2(ifftshift(s1)/255)));
I3=im2uint8(real(ifft2(ifftshift(s2)/255)));
I4=histeq(I3);
subplot(221),imshow(I1),title('');
subplot(222),imshow(I2),title('');
subplot(223),imshow(I3),title('');
subplot(224),imshow(I4),title('');