数据分割是由图像处理到图像分析的关键步骤,是图像识别和计算机视觉至关重要的预处理,图像分割后提取的目标可用于图像识别、特征提取,图像搜索等领域。图像分割的基本策略主要是基于图像灰度值的两个特性,即灰度的不连续性和灰度的相似性,因此图像分割方法可分为基于边缘的分割方法和基于区域的分割方法。本次实验通过完成简单的图像分割进一步加深对图像分割的理解。
进一步掌握MATLAB程序设计方法;
巩固图像分割理论与方法;
编程实现图像分割,比较基于阈值分割方法和基于边缘分割方法的效果,分析影响分割效果的因素。
计算机、Matlab图像处理软件、待处理图像
- 熟悉MATLAB中相关函数,掌握各函数的具体用法
help bwtraceboundary
bwtraceboundary Trace object in binary image.
B = bwtraceboundary(BW,P,FSTEP) traces the outline of an object in a binary image BW, in which nonzero pixels belong to an object and 0-pixels constitute the background. P is a two-element vector specifying the row and column coordinates of the initial point on the object boundary. FSTEP is a string or char vector specifying the initial search direction for the next object pixel connected to P. FSTEP can be any of the following strings or char vectors: ‘N’,‘NE’,‘E’,‘SE’,‘S’,‘SW’,‘W’,‘NW’, where N stands for north, NE stands for northeast, etc. B is a Q-by-2 matrix, where Q is the number of boundary pixels for the region. B holds the row and column coordinates of the boundary pixels.
B = bwtraceboundary(BW,P,FSTEP,CONN) specifies the connectivity to use when tracing the boundary. CONN may be either 8 or 4. The default value for CONN is 8. For CONN equal to 4, FSTEP is limited to ‘N’,‘E’,‘S’ and ‘W’.
B = bwtraceboundary(…,N,DIR) provides the option to specify the maximum number of boundary pixels, N, to extract and direction, DIR, in which to trace the boundary. DIR can be either ‘clockwise’ or ‘counterclockwise’. By default, or when N is set to Inf, the algorithmextracts all of the pixels from the boundary and, if DIR is not specified, it searches in the clockwise direction.
- 简单图像的阈值分割
(1)利用直方图进行阈值分割


图一 阈值分割
(2)利用最大类间方差自动确定阈值进行分割


图二 最大类间方差
3. 基于边缘的阈值分割
(1)利用各种边缘检测算子检测边缘


(2)边缘跟踪(bwtraceboundary)函数


图四 边缘跟踪
- Hough变换检测线段

图五 hough变换
- 图像分割是图像处理的重要步骤之一,在图像分割过程中算法是其主要的手法之一,但是每种算法有每种算法的特点,它的运行成果也行差万别。
- 实验中算法的编写总是出现各种各样的错误,经过细心的检查和耐心的改正错误基本都会改正错误。类型大致可分为:语法错误,函数调用,错误函数无法调用等类型。
版权声明:
本文来源网络,所有图片文章版权属于原作者,如有侵权,联系删除。
本文网址:https://www.mushiming.com/mjsbk/10056.html