资源简介
图像预处理算法。包括中值滤波,形态学滤波,二值化处理及图像背景校正
代码片段和文件信息
echo on
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 读取图像
f=imread(‘F:\myimage\noise experiment\test.BMP‘);
f=f(::1);
figure(1)
imshow(f)
pause
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 给图像添加噪声
g=imnoise(f‘salt & pepper‘0.09);
figure(2)
imshow(g)
title(‘椒盐噪声图像‘)
pause
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 中值滤波
J=medfilt2(g);
figure(3)
imshow(J)
title(‘中值滤波‘) %%%%%%%%%%%%%% 中值滤波
pause
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 形态学滤波
w3=strel(‘square‘3);
L=imopen(Jw3);
figure(6)
imshow(L)
title(‘开运算后的图像‘) %%%%%%%%%%%%%%%%%%% 开运算后的图像
m=imclose(Lw3);
figure(7)
imshow(m)
title(‘开运算后再闭运算后的图像‘) %%%%%%%%%%%%%% 开运算后再闭运算后的图像
pause
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 形态学灰度不均匀校正
w5=strel(‘square‘105);
n11=imclose(mw5);
figure(28)
imshow(n11)
title(‘经闭运算后的图像150‘)
NNN=imsubtract(n11m);
figure(29)
imshow(NNN)
title(‘顶帽变换150‘)
pause
close all
clc
level = graythresh(m);
BW = im2bw(mlevel);
figure imshow(BW)
pause
close all
clc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1448 2008-09-30 10:28 noise5.m
----------- --------- ---------- ----- ----
1666 2
评论
共有 条评论