欢迎光临散文网 会员登陆 & 注册

数字图像处理:空间域图像增强

2021-02-14 20:40 作者:乔知洛  | 我要投稿

实验目的:

1、掌握空间域的图像滤波增强

2、掌握频率域的图像滤波增强

实验内容及要求:

1、通过imfilter()进行平滑滤波

参考代码如下:

clear all;close all;

I=imread('eight.jpg');

J=imnoise(I,'salt & pepper',0.02);

h=ones(3,3)/5;

h(1,1)=0; h(1,3)=0;

h(3,1)=0; h(1,3)=0;

K=imfilter(J,h);

figure;

subplot(131);

imshow(I);

subplot(132);

imshow(J);

subplot(133);

imshow(K);

2、通过conv2()进行平滑滤波(均值滤波)

参考代码如下:

clear all;close all;

I=imread('rice.png');

I=im2double(I);

J=imnoise(I,'gaussian',0,0.01);

h=ones(3,3)/9;

K=conv2(J,h);

figure;

subplot(131);

imshow(I);

subplot(132);

imshow(J);

subplot(133);

imshow(K);

3、通过fspecial()和filter2()进行平滑滤波

参考代码如下:

clear all;close all;

I=imread('eight.jpg');

I=im2double(I);

J=imnoise(I,'salt & pepper',0.02);

h1=fspecial('average',3);

h2=fspecial('average',5);

K1=filter2(h1,J);

K2=filter2(h2,J);

figure;

subplot(131);

imshow(J);

subplot(132);

imshow(K1);

subplot(133);

imshow(K2);

4、通过medfilt2()进行中值滤波

参考代码如下:

clear all;close all;

I=imread('eight.jpg');

I=im2double(I);

J=imnoise(I,'salt & pepper',0.03);

K=medfilt2(J);

figure;

subplot(131);

imshow(J);

subplot(132);

imshow(J);

subplot(133);

imshow(K);

5、通过ordfilt2()进行排序滤波

参考代码如下:

clear all;close all;

I=imread('eight.jpg');

I=im2double(I);

J1=ordfilt2(I,1,true(5));

J2=ordfilt2(I,25,true(5));

figure;

subplot(131);

imshow(I);

subplot(132);

imshow(J1);

subplot(133);

imshow(J2);

6、通过wiener2()进行自适应滤波

参考代码如下:

clear all;close all;

I=imread('eight.jpg');

I=im2double(I);

J=imnoise(I,'gaussian',0,0.01);

K=wiener2(J,[5,5]);

figure;

subplot(131);

imshow(I);

subplot(132);

imshow(J);

subplot(133);

imshow(K);

7、通过拉普拉斯算子进行锐化滤波

参考代码如下:

clear all;close all;

I=imread('rice.png');

I=im2double(I);

h=[0,1,0;1,-4,1;0,1,0];

J=conv2(I,h,'same');

K=I-J;

figure;

subplot(121);

imshow(I);

subplot(122);

imshow(K);



数字图像处理:空间域图像增强的评论 (共 条)

分享到微博请遵守国家法律