30 lines
800 B
Matlab
30 lines
800 B
Matlab
close all
|
|
clear
|
|
clc
|
|
disp('====E4_7_3.m====');
|
|
|
|
I=imread('PIC4.7.6a.bmp');
|
|
subplot(2,3,1),imshow(I),xlabel('(a)原始图像'),ylabel('无噪声滤波过程');
|
|
|
|
K1=filter2(fspecial('average',3),I);
|
|
subplot(2,3,2),imshow(uint8(K1)),xlabel('(b)3*3模板均值滤波');
|
|
|
|
mask=[0 0 0
|
|
0 1 1
|
|
0 1 1];
|
|
mask=(1/4)*mask;
|
|
K2=filter2(mask,I);
|
|
subplot(2,3,3),imshow(uint8(K2)),xlabel('(c)选择模板均值滤波');
|
|
|
|
J=imnoise(I,'salt & pepper',0.4); % 语句1
|
|
subplot(2,3,4),imshow(J),xlabel('(a)噪声图像'),ylabel('有噪声滤波过程');
|
|
|
|
K3=filter2(fspecial('average',3),J);
|
|
subplot(2,3,5),imshow(uint8(K3)),xlabel('(b)3*3模板均值滤波');
|
|
|
|
mask=[0 0 0
|
|
0 1 1
|
|
0 1 1];
|
|
mask=(1/4)*mask;
|
|
K4=filter2(mask,J);
|
|
subplot(2,3,6),imshow(uint8(K4)),xlabel('(c)选择模板均值滤波');
|