This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DIPCV/lab3/lab4_3.m
2022-12-06 19:23:49 +08:00

34 lines
772 B
Matlab

close all
clear
clc
disp('====E4_7_4.m====');
I=imread('liftingbody.png');
subplot(2,3,1),imshow(I),xlabel('(a)原始图像');
J=imnoise(I,'salt & pepper',0.06);
subplot(2,3,2),imshow(J),xlabel('(b)噪声图像');
K1=filter2(fspecial('average',3),J);
subplot(2,3,3),imshow(uint8(K1)),xlabel('(c)3*3模板均值滤波');
mask1=[0 1 0
1 0 1
0 1 0];
mask1=(1/2)*mask1; % 语句1
K2=filter2(mask1,J);
subplot(2,3,4),imshow(uint8(K2)),xlabel('(d)4邻域模板均值滤波');
mask2=[1 1 1
1 0 1
1 1 1];
mask2=(1/16)*mask2; % 语句2
K3=filter2(mask2,J);
subplot(2,3,5),imshow(uint8(K3)),xlabel('(e)8邻域模板均值滤波');
mask3=[1 2 1
2 4 2
1 2 1];
mask3=(1/16)*mask3;
K4=filter2(mask3,J);
subplot(2,3,6),imshow(uint8(K4)),xlabel('(f)高斯模板均值滤波');