Matlab傅里叶变换和各种滤波处理资料讲解.docx

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

Matlab傅里叶变换和各种滤波处理资料讲解.docx

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

Matlab傅里叶变换和各种滤波处理资料讲解.docx

Matlab傅里叶变换和各种滤波处理资料讲解

 

Matlab傅里叶变换和各种滤波处理

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

傅里叶变换模和相位

img=imread('h:

\img.png');

f=fft2(img);%傅里叶变换

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

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

i=imag(f);%图像频域虚部

margin=log(abs(f));%图像幅度谱,加log便于显示

phase=log(angle(f)*180/pi);%图像相位谱

l=log(f);

subplot(2,2,1),imshow(img),title('源图像');

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

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

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

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

I=imread('h:

\img.png');

x=rgb2gray(I);

y1=imnoise(x,'gaussian',0,0.02);

f=double(y1);%数据类型转换,MATLAB不支持图像的无符号整型的计算

g=fft2(f);%傅立叶变换

g=fftshift(g);%转换数据矩阵

[M,N]=size(g);

nn=4;%四阶巴特沃斯(Butterworth)低通滤波器

d0=50;%截止频率为50

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

fori=1:

M

forj=1:

N

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

h=1/(1+0.414*(d/d0)^(2*nn));%计算低通滤波器传递函数

result(i,j)=h*g(i,j);

end

end

result=ifftshift(result);

y2=ifft2(result);

y3=uint8(real(y2));

subplot(1,2,1),imshow(y1),title('添加高斯噪声后的图像');

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

维纳滤波

I=imread('h:

\img.png');

x=rgb2gray(I);

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

J2=imnoise(x,'salt&pepper',0.02);%给图像添加椒盐噪声

J3=imnoise(x,'speckle',0.02);%给图像添加乘性噪声

Y1=wiener2(J1,[55]);%维纳滤波

Y2=wiener2(J2,[55]);

Y3=wiener2(J3,[55]);

subplot(2,2,1),imshow(x),title('灰度图');

subplot(2,2,2),imshow(Y1),title('高斯噪声维纳滤波');

subplot(2,2,3),imshow(Y2),title('椒盐噪声维纳滤波');

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

中值滤波

I=imread('h:

\img.png');

x=rgb2gray(I);

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

J2=imnoise(x,'salt&pepper',0.02);%给图像添加椒盐噪声

J3=imnoise(x,'speckle',0.02);%给图像添加乘性噪声

Y1=medfilt2(J1);%在默认3×3的邻域窗中进行中值滤波

Y2=medfilt2(J2);%在默认3×3的邻域窗中进行中值滤波

Y3=medfilt2(J3);%在默认3×3的邻域窗中进行中值滤波

subplot(2,2,1),imshow(x),title('灰度图');

subplot(2,2,2),imshow(Y1),title('高斯噪声中值滤波');

subplot(2,2,3),imshow(Y2),title('椒盐噪声中值滤波');

subplot(2,2,4),imshow(Y3),title('乘性噪声中值滤波');

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

I=imread('h:

\img.png');

I=rgb2gray(I);

figure

(1),imshow(I);

title('原图像');

s=fftshift(fft2(I));

figure

(2);

imshow(abs(s),[]);

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

[a,b]=size(s);

a0=round(a/2);

b0=round(b/2);

d=10;fori=1:

aforj=1:

b

distance=sqrt((i-a0)^2+(j-b0)^2);

ifdistance<=dh=1;

elseh=0;

end;

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

end;end;

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

figure(3);imshow(s);

title('低通滤波所得图像');

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

I=imread('h:

\img.png');

I=rgb2gray(I);

figure

(1),imshow(I);

title('原图像');

s=fftshift(fft2(I));

figure

(2);

imshow(abs(s),[]);

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

figure(3);imshow(log(abs(s)),[]);

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

[a,b]=size(s);a0=round(a/2);b0=round(b/2);

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

a

forj=1:

b

distance=sqrt((i-a0)^2+(j-b0)^2);

ifdistance<=dh=0;

elseh=1;end;

s(i,j)=(p+q*h)*s(i,j);end;end;

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

figure(4);imshow(s);

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

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

title('高通滤波所得高频增强图像');

其他函数滤波

I=imread('h:

\img.png');

J=imnoise(I,'gaussian',0.001,0.01);%高斯噪声定义

A=fspecial('average',[33]);%定义average滤波器

B=fspecial('gaussian',[33],0.5);%定义gaussian滤波器

C=fspecial('motion',9,0);%定义motion滤波器

D=fspecial('unsharp',0.2);%定义unsharp滤波器

subplot(2,3,1);imshow(I);title('(a)原始图像');

%为图像叠加高斯噪声

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

subplot(2,3,3);imshow(h1);title('(c)average滤波图');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=imfilter(J,D);%对图像进行unsharp滤波

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

figure;%新建图像窗口

K=imnoise(I,'salt&pepper',0.1);%定义椒盐噪声

subplot(2,3,1);imshow(I);title('(a)原始图像');

%为图像叠加椒盐噪声

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

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

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

subplot(2,3,5);imshow(l3);title('(e)motion滤波图');l4=imfilter(K,B);%对图像进行unsharp滤波

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

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

当前位置:首页 > 法律文书 > 辩护词

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

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