傅里叶变换模和相位和各种滤波处理.docx

上传人:b****2 文档编号:25731092 上传时间:2023-06-12 格式:DOCX 页数:15 大小:324.33KB
下载 相关 举报
傅里叶变换模和相位和各种滤波处理.docx_第1页
第1页 / 共15页
傅里叶变换模和相位和各种滤波处理.docx_第2页
第2页 / 共15页
傅里叶变换模和相位和各种滤波处理.docx_第3页
第3页 / 共15页
傅里叶变换模和相位和各种滤波处理.docx_第4页
第4页 / 共15页
傅里叶变换模和相位和各种滤波处理.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

傅里叶变换模和相位和各种滤波处理.docx

《傅里叶变换模和相位和各种滤波处理.docx》由会员分享,可在线阅读,更多相关《傅里叶变换模和相位和各种滤波处理.docx(15页珍藏版)》请在冰豆网上搜索。

傅里叶变换模和相位和各种滤波处理.docx

傅里叶变换模和相位和各种滤波处理

MatIab傅里叶变换模和相位和各种滤波处理

傅里叶变换模和相位

img=imread(,h:

\img.png');

仁fft2(img);%傅里叶变换

仁fftshift(f);%使图像对称

r=real(f);%图像频域实部

i=imag⑴;%图像频域虚部

margin=log(abs(f));%图像幅度谱,加log便于显示phase=log(angle(f)*180/pi);%图像相位谱

l=log(f);

subplot(2,2,l)/imshow(img),title('源图像');subplot(2,2,2),imshow(l,[]),title('图像频谱');

subplot(2,2,3),imshow(margin,[]),title('图像幅度谱');subplot(2,2,4),imshow(phase,[]),title('图像相位谱');

添加高斯噪声、四阶巴特沃斯低通滤波

kimreadf'hAimg.png');x=rgb2gray(l);yl=imnoise(x/gaussian',0,0.02);

f=double(yl);g=fft2(f);g=fftshift(g);(M/N]=size(g);nn=4;

d0=50;

m=fix(M/2);n=fix(N/2);

%数据类型转换,MATLAB不支持图像的无符号整型的汁算

%傅立叶变换

%转换数据矩阵

%四阶巴特沃斯(Butterworth)低通滤波器

%截止频率为50

fori=l:

M

forj=l:

N

d=sqrt((i-m)A2+(j-n)A2);

h=l/(l+0.414*(d/d0)A(2*nn));%计算低通滤波器传递函数result(ij)=h*g(ij);

end

endresult=ifftshift(result);y2=ifft2(result);

y3=uint8(real(y2));

subplot(l/2/l)/imshow(yl)/title(,添加髙斯噪声后的图像');

subplot(l/2/2)/imshow(y3)/title(,四阶巴特沃斯低通滤波图像');

维纳滤波

kimreadChAimg.png1);

x=rgb2gray(l);

Jl=imnoise(x,,gaussian,/0/0.02);%给图像添加高斯噪声J2=imnoise(x,'salt&pepper',0.02);%给图像添加椒盐噪声J3=imnoise(x/,speckle,/0.02);%给图像添加乘性噪声

Yl=wiener2(Jl/[55]);%维纳滤波

Y2=wiener2(J2/[55]);

Y3=wiener2(J3,[55]);

subplot(2/2/l),imshow(x)/title(,灰度图');subplot(2,2,2),imshow(Yl),title('髙斯噪声维纳滤波');subplot(2/2/3),imshow(Y2),title(,椒盐噪声维纳滤波');

subplot(2/2,4),imshow(Y3)/title(,^性噪声维纳滤波');

 

灰度图

高斯噪声维纳滤液

 

 

椒盐噪声维纳滤波

乘性噪声维纳滤波

 

 

中值滤波

l=imread(h\img.png/);

x=rgb2gray(l);

J1=imnoise(x.'gaussian'.0,0.02);%给图像添加高斯噪声

J2=imnoise(x,'salt&pepperJ0・02);%给图像添加椒盐噪声J3=imnoise(x.'speckle*.0.02);%给图像添加乘性噪声

Y1=medfilt2(J1)在默认3X3的邻域窗中进行中值滤波Y2=medfilt2(J2)俺在默认3X3的邻域窗中进行中值滤波Y3=medfilt2(J3)俺在默认3X3的邻域窗中进行中值滤波subplot(2,2r1).imshow(x),title(*灰度图’);subplot(2.2,2),imshow(Y1),titleC高斯噪声中值滤波');subplot(2.2,3),imshow(Y2),title('椒盐噪声中值滤波');subplot(2.2,4).imshow(Y3).title(*乘性噪声中值滤波J;

灰度图

高斯噪声中值滤液

 

 

椒盐噪声中值滤淤

乘性噪声中值滤液

 

低通滤波器在频率域实现低通滤波

l=imread('h:

\img.png*);

I=rgb2gray(l);

figured),imshow(l);

title('原图像');

s=fftshift(fft2(l));

figure

(2);

imshow(abs(s).[]);

ti11eC图像傅里叶变换所得频谱1);

[a,b]=size(s);

aO=round(a/2);

bO=round(b/2);

d=10;fori=1:

aforj=1:

b

distance=sqrt((i-aO)"2+(j-bO)"2);

ifdistance<=dh=1;

elseh=0;

end;

s(i,j)=h*s(i,j);

end;end;

s=uint8(reaI(ifft2(ifftshift(s))));

figure(3);imshow(s);

titled低通滤波所得图像J;

 

原團像

團像傅里叶变换所得频谱

低通•應波所得團像

 

 

高通滤波器在频率域实现高频增强

I二imread('h:

\img.png');

I=rgb2gray(l);

figured),imshow(l);

titleC原图像J;

s=fftshift(fft2(l));

figure

(2);

imshow(abs(s),[]);

ti11e('图像傅里叶变换所得频谱');

figure(3);imshow(Iog(abs(s)).[]);

ti11eC图像傅里叶变换取对数所得频谱');

[a,b]=size(s);aO=round(a/2);bO=round(b/2);

d=10;p=0.2;q=0.5;fori=1:

a

forj=1:

b

distance=sqrt((i-aO)"2+(j-bO)"2);

ifdistance<=dh=0;

elseh=1;end;

s(i.j)=(p+q*h)*s(i.j);end;end;s=uint8(reaI(ifft2(ifftshift(s))));

figure(4);imshow(s);

title(,高通滤波所得图像,);

figure(5);imshow(s+1);

ti11eC高通滤波所得高频增强图像J;

回区碍里叶荧携观対毅阳徇気ii

所胃育预帘毬ea像

 

其他函数滤波

I二imread('h:

\img・png');

J=imnoisefl/gaussian1,0.001,0.01);%离斯噪声定义

A=fspecialCaverage1,[33]);%定义average滤波器

B=fspecialfgaussian',[33]z0・5);%定义gaussian滤波器

C=fspecialfmotion1,9,0);%定义motion滤波器

D=fspecialCunsharp1,0.2);%定义unsharp滤波器subplot(2,3/l);imshow(l);title(l(a)原始图像');

%为图像叠加髙斯噪声

subplot(2,3/2);imshow{J);title(l(b)叠加高斯噪声图');hl=imfilter(JzA);%对图像进行average滤波

subplot(2,3/3);imshow(hl);title(,(c)average滤波图J;h2=imfilter(J,B);%对图像进行gaussian滤波

subplot(2,3/4);imshow(h2);title(,(d)gaussian滤波图');h3=imfilter(J,C);%对图像进行motion滤波

subplot(2,3/5);imshow(h3);title(,(e)motion滤波图');h4=imfiltw电D);%对图像进行unsharp滤波

subplot(2,3/6);imshow{h4);title('(f)unsharp滤波图');

figure;%新建图像窗口

K=imnoise(l/salt&pepper^O.l);%^义椒盐噪声subplot(2,3/l);imshow(l);title(l(a)原始图像');

%为图像叠加椒盐噪声

subplot(2/3,2);imshow(J);title(,(b)叠加椒盐噪声图=imfilter(K,A);%对图像进行average滤波

subplot(2,3/3);imshow{ll);title(,(c)average滤波图');I2=imfilter(K,B);%对图像进行gaussian滤波

subplot(2,3/4);imshow(l2);title(,(d)gaussion滤波图');I3=imfilter(K,B);%对图像进行motion滤波

subplot(2,3/5);imshow(l3);title(,(e)motion滤波图');I4二imfilter(K’B);%对图像进彳亍unsharp滤波

subplot(2,3/6);imshow(l4);title(,(f)unsharp滤波图');

 

(b)蠡加高斯噪声團

(c)average滤波團

(e)motion滤波團

(d)gaussian滤波團

(f)unsharp滤波图

(a>原始图像

(b)疊加椒盐噪声图

(c)average滤波图

(d)gaussion滤波團

(f)unsharp滤波图

 

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1