首页 > 编程知识 正文

matlab数字图像处理大作业,matlab数字图像处理基本语言

时间:2023-05-05 11:39:58 阅读:135518 作者:2961

一、原理_频率域平滑

理想低通滤波器的传递函数为:

n 阶巴特crdfn低通滤波器的传递函数为:

n 阶指数低通滤波器的传递函数为:

二、步骤

(1)读入原图像test.tif并显示;
(2)对原图像添加高斯噪声;
(3)采用理想低通滤波器对加噪图像滤波,并显示滤波结果;
观察截止频率 D0 分别为15、30、80时,理想低通滤波的结果。
(4)采用二阶巴特crdfn低通滤波器对加噪图像滤波,并显示滤波结果;
观察截止频率 D0 分别为15、30、80时,二阶巴特crdfn低通滤波的结果。
(5)采用二阶指数低通滤波器对加噪图像滤波,并显示滤波结果;
观察截止频率 D0 分别为15、30、80时,二阶指数低通滤波的结果。
(6)比较各种低通滤波器的滤波效果。

三、实验图像

test.tif 将图片存到路径:D:test.tif 四、框图

五、代码 %------------------------------------------------------------------------% File name: first_3% Last modified Date: 2021年6月17日09点57分% Author: Jasmine% Descriptions: 频率域平滑%------------------------------------------------------------------------%清空工作区clc,clear,close all;%获取图像img = imread('D:test.tif');img_noise = imnoise(img, 'gaussian', 0, 0.02);I = im2double(img_noise);[m, n] = size(I);n2 = 2*n;m2 = 2*m;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%进行fft变换并移到中心F = fftshift(fft2(I, m2, n2));figure(1);subplot(4,3,2),imshow(mat2gray(log(1+abs(F)))),title('加噪图像 频谱图')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%设计滤波器%生成网格坐标u = -n:n-1;v = -m:m-1;[U,V] = meshgrid(u,v);D = hypot(U, V);D0 = 15;D1 = 30;D2 = 80; %[15, 30, 80]%各滤波器的系统函数H11 = mat2gray( D <= D0 );%理想低通滤波器截止频率为15H12 = mat2gray( D <= D1 );%理想低通滤波器截止频率为30H13 = mat2gray( D <= D2 );%理想低通滤波器截止频率为80H21 = mat2gray(1./(1+((D./D0).^4)));%巴特crdfn低通滤波器截止频率为15H22 = mat2gray(1./(1+((D./D1).^4)));%巴特crdfn低通滤波器截止频率为30H23 = mat2gray(1./(1+((D./D2).^4)));%巴特crdfn低通滤波器截止频率为80H31 = mat2gray(exp(-(D./D0).^2));%指数低通滤波器截止频率为15H32 = mat2gray(exp(-(D./D1).^2));%指数低通滤波器截止频率为30H33 = mat2gray(exp(-(D./D2).^2));%指数低通滤波器截止频率为80%滤波器的系统函数与图像频谱变换相乘G11 = F.*H11;subplot(4,3,4);imshow(mat2gray(log(1+abs(G11))));title('理想低通滤波15 频谱图');G12 = F.*H12;subplot(4,3,5);imshow(mat2gray(log(1+abs(G12))));title('理想低通滤波30 频谱图');G13 = F.*H13;subplot(4,3,6);imshow(mat2gray(log(1+abs(G13))));title('理想低通滤波80 频谱图');G21 = F.*H21;subplot(4,3,7);imshow(mat2gray(log(1+abs(G21))));title('巴特crdfn低通滤波15 频谱图');G22 = F.*H22;subplot(4,3,8);imshow(mat2gray(log(1+abs(G22))));title('巴特crdfn低通滤波30 频谱图');G23 = F.*H23;subplot(4,3,9);imshow(mat2gray(log(1+abs(G23))));title('巴特crdfn低通滤波80 频谱图');G31 = F.*H31;subplot(4,3,10);imshow(mat2gray(log(1+abs(G31))));title('指数低通滤波15 频谱图');G32 = F.*H32;subplot(4,3,11);imshow(mat2gray(log(1+abs(G32))));title('指数低通滤波30 频谱图');G33 = F.*H33;subplot(4,3,12);imshow(mat2gray(log(1+abs(G33))));title('指数低通滤波80 频谱图');%傅里叶反变换g011 = ifft2(fftshift(G11));g11 = g011(1:m,1:n);g11 = real(g11);g012 = ifft2(fftshift(G12));g12 = g012(1:m,1:n);g12 = real(g12);g013 = ifft2(fftshift(G13));g13 = g013(1:m,1:n);g13 = real(g13);g021 = ifft2(fftshift(G21));g21 = g021(1:m,1:n);g21 = real(g21);g022 = ifft2(fftshift(G22));g22 = g022(1:m,1:n);g22 = real(g22);g023 = ifft2(fftshift(G23));g23 = g023(1:m,1:n);g23 = real(g23);g031 = ifft2(fftshift(G31));g31 = g031(1:m,1:n);g31 = real(g31);g032 = ifft2(fftshift(G32));g32 = g032(1:m,1:n);g32 = real(g32);g033 = ifft2(fftshift(G33));g33 = g033(1:m,1:n);g33 = real(g33);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%输出各图像figure(2);subplot(4,3,1);imshow(img);title('原始图像');subplot(4,3,2);imshow(img_noise);title('添加 均值:0 方差:0.02 高斯噪声的图像');subplot(4,3,4);imshow(g11);title(['理想低通滤波 D0=',num2str(D0)]);subplot(4,3,5);imshow(g12);title(['理想低通滤波 D0=',num2str(D1)]);subplot(4,3,6);imshow(g13);title(['理想低通滤波 D0=',num2str(D2)]);subplot(4,3,7);imshow(g21);title(['巴特crdfn低通滤波 D0=',num2str(D0)]);subplot(4,3,8);imshow(g22);title(['巴特crdfn低通滤波 D0=',num2str(D1)]);subplot(4,3,9);imshow(g23);title(['巴特crdfn低通滤波 D0=',num2str(D2)]);subplot(4,3,10);imshow(g31);title(['指数低通滤波 D0=',num2str(D0)]);subplot(4,3,11);imshow(g32);title(['指数低通滤波 D0=',num2str(D1)]);subplot(4,3,12);imshow(g33);title(['指数低通滤波 D0=',num2str(D2)]); 六、运行结果

频率域平滑各滤波器的频谱图 观察实验结果可知,随着低通滤波器截止频率的增大,图像变得更加清晰;巴特crdfn低通滤波器和指数低通滤波器可以较好地实现低通滤波器的效果。

频率域平滑各滤波器的频谱图 观察到下列各滤波器的频谱图,可以看出随着低通滤波器截止频率的增大,中间白色部分变得越来越大。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。