<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="generator" content="pdf2htmlEX">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css">
<link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css">
<link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b5d533d2fbb0007ab85cf/raw.css">
<script src="https://static.pudn.com/base/js/compatibility.min.js"></script>
<script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script>
<script>
try{
pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});
}catch(e){}
</script>
<title></title>
</head>
<body>
<div id="sidebar" style="display: none">
<div id="outline">
</div>
</div>
<div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b5d533d2fbb0007ab85cf/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">matlab <span class="ff2 sc1">图像分割算法源码</span></div><div class="t m0 x1 h4 y3 ff3 fs1 fc1 sc0 ls0 ws0">1.<span class="ff2">图像反转</span></div><div class="t m0 x1 h4 y4 ff3 fs1 fc1 sc0 ls0 ws0">MATLAB<span class="_ _0"> </span><span class="ff2">程序实现如下:</span></div><div class="t m0 x1 h5 y5 ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 y6 ff3 fs1 fc1 sc0 ls0 ws0">J=double(I);</div><div class="t m0 x1 h4 y7 ff3 fs1 fc1 sc0 ls0 ws0">J=-J+(256-1);!!!!!!!!!!!!!!!! %<span class="ff2">图像反转线性变换</span></div><div class="t m0 x1 h5 y8 ff3 fs1 fc1 sc0 ls0 ws0">H=uint8(J);</div><div class="t m0 x1 h5 y9 ff3 fs1 fc1 sc0 ls0 ws0">subplot(1,2,1),imshow(I);</div><div class="t m0 x1 h5 ya ff3 fs1 fc1 sc0 ls0 ws0">subplot(1,2,2),imshow(H);</div><div class="t m0 x1 h4 yb ff3 fs1 fc1 sc0 ls0 ws0">2.<span class="ff2">灰度线性变换</span></div><div class="t m0 x1 h4 yc ff3 fs1 fc1 sc0 ls0 ws0">MATLAB<span class="_ _0"> </span><span class="ff2">程序实现如下:</span></div><div class="t m0 x1 h5 yd ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 ye ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,1),imshow(I);</div><div class="t m0 x1 h4 yf ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">原始图像</span>');</div><div class="t m0 x1 h5 y10 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y11 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h5 y12 ff3 fs1 fc1 sc0 ls0 ws0">I1=rgb2gray(I);</div><div class="t m0 x1 h5 y13 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,2),imshow(I1);</div><div class="t m0 x1 h4 y14 ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">灰度图像</span>');</div><div class="t m0 x1 h5 y15 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y16 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y17 ff3 fs1 fc1 sc0 ls0 ws0">J=imadjust(I1,[0.1 0.5],[]); %<span class="ff2">局部拉伸,把</span>[0.1 0.5]<span class="ff2">内的灰度拉伸为</span>[0 1]</div><div class="t m0 x1 h5 y18 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,3),imshow(J);</div><div class="t m0 x1 h4 y19 ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">线性变换图像</span>[0.1 0.5]');</div><div class="t m0 x1 h5 y1a ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y1b ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y1c ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y1d ff3 fs1 fc1 sc0 ls0 ws0">K=imadjust(I1,[0.3 0.7],[]); %<span class="ff2">局部拉伸,把</span>[0.3 0.7]<span class="ff2">内的灰度拉伸为</span>[0 1]</div><div class="t m0 x1 h5 y1e ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,4),imshow(K);</div><div class="t m0 x1 h4 y1f ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">线性变换图像</span>[0.3 0.7]');</div><div class="t m0 x1 h5 y20 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y21 ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y22 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y23 ff3 fs1 fc1 sc0 ls0 ws0">3.<span class="ff2">非线性变换</span></div><div class="t m0 x1 h4 y24 ff3 fs1 fc1 sc0 ls0 ws0">MATLAB<span class="_ _0"> </span><span class="ff2">程序实现如下:</span></div><div class="t m0 x1 h5 y25 ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 y26 ff3 fs1 fc1 sc0 ls0 ws0">I1=rgb2gray(I);</div><div class="t m0 x1 h5 y27 ff3 fs1 fc1 sc0 ls0 ws0">subplot(1,2,1),imshow(I1);</div><div class="t m0 x1 h4 y28 ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">灰度图像</span>');</div><div class="t m0 x1 h5 y29 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y2a ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y2b ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div>
</body>
</html>
<div id="pf2" class="pf w0 h0" data-page-no="2"><div class="pc pc2 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b5d533d2fbb0007ab85cf/bg2.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h5 y2c ff3 fs1 fc1 sc0 ls0 ws0">J=double(I1);</div><div class="t m0 x1 h5 y2d ff3 fs1 fc1 sc0 ls0 ws0">J=40*(log(J+1));</div><div class="t m0 x1 h5 y2e ff3 fs1 fc1 sc0 ls0 ws0">H=uint8(J);</div><div class="t m0 x1 h5 y5 ff3 fs1 fc1 sc0 ls0 ws0">subplot(1,2,2),imshow(H);</div><div class="t m0 x1 h4 y2f ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">对数变换图像</span>');</div><div class="t m0 x1 h5 y30 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y31 ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y32 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y33 ff3 fs1 fc1 sc0 ls0 ws0">4.<span class="ff2">直方图均衡化</span></div><div class="t m0 x1 h4 yb ff3 fs1 fc1 sc0 ls0 ws0">MATLAB<span class="_ _0"> </span><span class="ff2">程序实现如下:</span></div><div class="t m0 x1 h5 y34 ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 yd ff3 fs1 fc1 sc0 ls0 ws0">I=rgb2gray(I);</div><div class="t m0 x1 h5 ye ff3 fs1 fc1 sc0 ls0 ws0">figure;</div><div class="t m0 x1 h5 y35 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,1);</div><div class="t m0 x1 h5 y10 ff3 fs1 fc1 sc0 ls0 ws0">imshow(I);</div><div class="t m0 x1 h5 y36 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,2);</div><div class="t m0 x1 h5 y12 ff3 fs1 fc1 sc0 ls0 ws0">imhist(I);</div><div class="t m0 x1 h5 y13 ff3 fs1 fc1 sc0 ls0 ws0">I1=histeq(I);</div><div class="t m0 x1 h5 y37 ff3 fs1 fc1 sc0 ls0 ws0">figure;</div><div class="t m0 x1 h5 y15 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,1);</div><div class="t m0 x1 h5 y38 ff3 fs1 fc1 sc0 ls0 ws0">imshow(I1);</div><div class="t m0 x1 h5 y39 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,2);</div><div class="t m0 x1 h5 y18 ff3 fs1 fc1 sc0 ls0 ws0">imhist(I1);</div><div class="t m0 x1 h4 y3a ff3 fs1 fc1 sc0 ls0 ws0">5.<span class="ff2">线性平滑滤波器</span></div><div class="t m0 x1 h4 y3b ff2 fs1 fc1 sc0 ls0 ws0">用<span class="_ _0"> </span><span class="ff3">MATLAB<span class="_ _0"> </span></span>实现领域平均法抑制噪声程序:</div><div class="t m0 x1 h5 y3c ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 y3d ff3 fs1 fc1 sc0 ls0 ws0">subplot(231)</div><div class="t m0 x1 h5 y3e ff3 fs1 fc1 sc0 ls0 ws0">imshow(I)</div><div class="t m0 x1 h4 y3f ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">原始图像</span>')</div><div class="t m0 x1 h5 y40 ff3 fs1 fc1 sc0 ls0 ws0">I=rgb2gray(I);</div><div class="t m0 x1 h5 y41 ff3 fs1 fc1 sc0 ls0 ws0">I1=imnoise(I,'salt & pepper',0.02);</div><div class="t m0 x1 h5 y42 ff3 fs1 fc1 sc0 ls0 ws0">subplot(232)</div><div class="t m0 x1 h5 y43 ff3 fs1 fc1 sc0 ls0 ws0">imshow(I1)</div><div class="t m0 x1 h4 y23 ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">添加椒盐噪声的图像</span>')</div><div class="t m0 x1 h4 y24 ff3 fs1 fc1 sc0 ls0 ws0">k1=filter2(fspecial('average',3),I1)/255;<span class="_ _1"></span>!!!!!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>3*3<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span></div><div class="t m0 x1 h4 y44 ff3 fs1 fc1 sc0 ls0 ws0">k2=filter2(fspecial('average',5),I1)/255;<span class="_ _1"></span>!!!!!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>5*5<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span></div><div class="t m0 x1 h4 y45 ff3 fs1 fc1 sc0 ls0 ws0">k3=filter2(fspecial('average',7),I1)/255;<span class="_ _1"></span>!!!!!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>7*7<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span></div><div class="t m0 x1 h4 y46 ff3 fs1 fc1 sc0 ls0 ws0">k4=filter2(fspecial('average',9),I1)/255;<span class="_ _1"></span>!!!!!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>9*9<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span></div><div class="t m0 x1 h4 y28 ff3 fs1 fc1 sc0 ls0 ws0">subplot(233),imshow(k1);title('3*3<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span>');</div><div class="t m0 x1 h4 y47 ff3 fs1 fc1 sc0 ls0 ws0">subplot(234),imshow(k2);title('5*5<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span>');</div><div class="t m0 x1 h4 y2a ff3 fs1 fc1 sc0 ls0 ws0">subplot(235),imshow(k3);title('7*7<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span>');</div><div class="t m0 x1 h4 y2b ff3 fs1 fc1 sc0 ls0 ws0">subplot(236),imshow(k4);title('9*9<span class="_ _0"> </span><span class="ff2">模板平滑滤波</span>');</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div>
<div id="pf3" class="pf w0 h0" data-page-no="3"><div class="pc pc3 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b5d533d2fbb0007ab85cf/bg3.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h4 y48 ff3 fs1 fc1 sc0 ls0 ws0">6.<span class="ff2">中值滤波器</span></div><div class="t m0 x1 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">用<span class="_ _0"> </span><span class="ff3">MATLAB<span class="_ _0"> </span></span>实现中值滤波程序如下:</div><div class="t m0 x1 h5 y2e ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 y5 ff3 fs1 fc1 sc0 ls0 ws0">I=rgb2gray(I);</div><div class="t m0 x1 h5 y6 ff3 fs1 fc1 sc0 ls0 ws0">J=imnoise(I,'salt&pepper',0.02);</div><div class="t m0 x1 h4 y7 ff3 fs1 fc1 sc0 ls0 ws0">subplot(231),imshow(I);title('<span class="ff2">原图像</span>');</div><div class="t m0 x1 h4 y31 ff3 fs1 fc1 sc0 ls0 ws0">subplot(232),imshow(J);title('<span class="ff2">添加椒盐噪声图像</span>');</div><div class="t m0 x1 h4 y32 ff3 fs1 fc1 sc0 ls0 ws0">k1=medfilt2(J);!!!!!!!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>3*3<span class="_ _0"> </span><span class="ff2">模板中值滤波</span></div><div class="t m0 x1 h4 y49 ff3 fs1 fc1 sc0 ls0 ws0">k2=medfilt2(J,[5,5]);!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>5*5<span class="_ _0"> </span><span class="ff2">模板中值滤波</span></div><div class="t m0 x1 h4 y4a ff3 fs1 fc1 sc0 ls0 ws0">k3=medfilt2(J,[7,7]);!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>7*7<span class="_ _0"> </span><span class="ff2">模板中值滤波</span></div><div class="t m0 x1 h4 y4b ff3 fs1 fc1 sc0 ls0 ws0">k4=medfilt2(J,[9,9]);!!!!! %<span class="ff2">进行<span class="_ _0"> </span></span>9*9<span class="_ _0"> </span><span class="ff2">模板中值滤波</span></div><div class="t m0 x1 h4 y4c ff3 fs1 fc1 sc0 ls0 ws0">subplot(233),imshow(k1);title('3*3<span class="_ _0"> </span><span class="ff2">模板中值滤波</span>');</div><div class="t m0 x1 h4 y4d ff3 fs1 fc1 sc0 ls0 ws0">subplot(234),imshow(k2);title('5*5<span class="_ _0"> </span><span class="ff2">模板中值滤波</span>');</div><div class="t m0 x1 h4 y4e ff3 fs1 fc1 sc0 ls0 ws0">subplot(235),imshow(k3);title('7*7<span class="_ _0"> </span><span class="ff2">模板中值滤波</span>');</div><div class="t m0 x1 h4 y4f ff3 fs1 fc1 sc0 ls0 ws0">subplot(236),imshow(k4);title('9*9<span class="_ _0"> </span><span class="ff2">模板中值滤波</span>');</div><div class="t m0 x1 h6 y50 ff1 fs2 fc2 sc0 ls0 ws0">7.<span class="ff2 sc2">用<span class="_ _2"> </span></span>Sobel<span class="_ _2"> </span><span class="ff2 sc2">算子和拉普拉斯对图像锐化:</span></div><div class="t m0 x1 h5 y13 ff3 fs1 fc1 sc0 ls0 ws0">I=imread('xian.bmp');</div><div class="t m0 x1 h5 y37 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,1),imshow(I);</div><div class="t m0 x1 h4 y51 ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">原始图像</span>');</div><div class="t m0 x1 h5 y38 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y17 ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y52 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h5 y53 ff3 fs1 fc1 sc0 ls0 ws0">I1=im2bw(I);</div><div class="t m0 x1 h5 y1a ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,2),imshow(I1);</div><div class="t m0 x1 h4 y1b ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">二值图像</span>');</div><div class="t m0 x1 h5 y54 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y1d ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y55 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y1f ff3 fs1 fc1 sc0 ls0 ws0">H=fspecial('sobel');!!!! %<span class="ff2">选择<span class="_ _0"> </span></span>sobel<span class="_ _0"> </span><span class="ff2">算子P</span></div><div class="t m0 x1 h4 y56 ff3 fs1 fc1 sc0 ls0 ws0">J=filter2(H,I1);!!!!!!!!!!! %<span class="ff2">卷积运算</span></div><div class="t m0 x1 h5 y57 ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,3),imshow(J);!</div><div class="t m0 x1 h4 y22 ff3 fs1 fc1 sc0 ls0 ws0">title('sobel<span class="_ _0"> </span><span class="ff2">算子锐化图像</span>');</div><div class="t m0 x1 h5 y58 ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y59 ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y5a ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div><div class="t m0 x1 h4 y5b ff3 fs1 fc1 sc0 ls0 ws0">h=[0 1 0,1 -4 1,0 1 0];!! %<span class="ff2">拉普拉斯算子</span></div><div class="t m0 x1 h4 y5c ff3 fs1 fc1 sc0 ls0 ws0">J1=conv2(I1,h,'same');!!!!!!!!!!! %<span class="ff2">卷积运算</span></div><div class="t m0 x1 h5 y5d ff3 fs1 fc1 sc0 ls0 ws0">subplot(2,2,4),imshow(J1);!</div><div class="t m0 x1 h4 y5e ff3 fs1 fc1 sc0 ls0 ws0">title('<span class="ff2">拉普拉斯算子锐化图像</span>');</div><div class="t m0 x1 h5 y5f ff3 fs1 fc1 sc0 ls0 ws0">axis([50,250,50,200]);</div><div class="t m0 x1 h4 y60 ff3 fs1 fc1 sc0 ls0 ws0">grid on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示网格线</span></div><div class="t m0 x1 h4 y61 ff3 fs1 fc1 sc0 ls0 ws0">axis on;!!!!!!!!!!!!!!!!! %<span class="ff2">显示坐标系</span></div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div>