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

35 lines
772 B
Mathematica
Raw Normal View History

2022-11-21 03:42:00 +00:00
close all
clear
clc
disp('====E4_7_4.m====');
I=imread('liftingbody.png');
subplot(2,3,1),imshow(I),xlabel('(a)ԭʼͼ<EFBFBD><EFBFBD>');
J=imnoise(I,'salt & pepper',0.06);
subplot(2,3,2),imshow(J),xlabel('(b)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>');
K1=filter2(fspecial('average',3),J);
subplot(2,3,3),imshow(uint8(K1)),xlabel('(c)3*3ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>˲<EFBFBD>');
mask1=[0 1 0
1 0 1
0 1 0];
mask1=(1/2)*mask1; % <EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
K2=filter2(mask1,J);
subplot(2,3,4),imshow(uint8(K2)),xlabel('(d)4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>˲<EFBFBD>');
mask2=[1 1 1
1 0 1
1 1 1];
mask2=(1/16)*mask2; % <EFBFBD><EFBFBD><EFBFBD><EFBFBD>2
K3=filter2(mask2,J);
subplot(2,3,5),imshow(uint8(K3)),xlabel('(e)8<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>˲<EFBFBD>');
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)<EFBFBD><EFBFBD>˹ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>˲<EFBFBD>');