当前位置:文档之家› 机器视觉(2)

机器视觉(2)


四连通和八连通
4
2013/10/19
连通性
路径(path) 从像素 f i0 , j0 到像素 f in , jn 的路径是像素序列:
连通性
连通成分(connected components) 如果像素集合中每个像素均与所有其它像素是连通 的,那么这个像素集合称为连通成分。 背景(background) 在像素集合 S (集合 S 的余集)中拥有图像边界像 素的所有连通成分集合称为背景, S 中的其它成分 称为孔。 边缘(boundary) 像素集合 S 的边缘是与像素集合 S 中像素具有四连 通关系的像素集合,记为 S’ 。
游程编码
游程编码使用数字来表示图像中取值为 1 像素游程 的长度。 游程编码已经应用于图像传输。
Hi j 0 FT i, j
n 1
V j i 0 FT i, j
m 1
连通性
在方形网格采样下,数字图像中的每个像素均与四 个像素具有相同的边,与另外四个像素共享相同的 角点。 如果两个像素共享相同的边,则称这两个像素是四 连通的(4‐connected)。 如果两个像素共享相同的角点,则称这两个像素是 八连通的(8‐connected)。
几何性质
面积(area):
A FT i, j
i 0 j 0
m 1 n 1
位置(position)(坐标原点为左上角像素):
x
m 1 i 0 m 1
n 1 j 0
jFT i, j
y
i 0 j 0 iFT i, j
n 1
AБайду номын сангаас
连通性
内点(interior) 像素集合 S 的内点为 S – S’ 。 包围(surrounds) 如果从区域 S 中任意一点到图像边缘的四连通路径 必须与区域 T 相交,则称 T 包围 S (或 S 在 T 内)。
连通成分标记
在图像中发现连通成分是机器视觉中最常用的操作 之一。 连通成分中的点形成表示一个物体的候选区域。
A
几何性质
方向(orientation):
几何性质
伸张度(elongation):
tan 1
m 1
FT i, j a i 0 j 0 xij
n 1 2
1 2 where :
b ac
E
max min
where : 1 a c 1 a c cos 2 1 b sin 2 2 2 2 b sin 2 2 b 2 a c
5
2013/10/19
连通成分标记的递归算法
Algorithm 2.1: Recursive connected components algorithm 1. 2. 3. 4. Scan the image to find an unlabeled 1 pixel and assign it a new label L. Recursively assign a label L to all its 1 neighbors. Stop if there are no more unlabeled 1 pixels. Go to step 1.
f i0 , j0 , f i1 , j1 , f i2 , j2 ,, f in , jn 对所有的 k 0 k n 1 , f ik , jk 和 f ik 1 , jk 1 是 邻点。
前景(foreground) 图像中所有取值为 1 的像素集合,用 S 表示。 连通性(connectivity) 如果从像素 p S 到像素 q S 的路径完全由 S 中的 像素组成,则称 p 和 q 是连通的。
7
2013/10/19
中心矩
由于矩 m pq 具有平移不变性,故 p q 阶中心矩为:
pq
x , y
矩不变量
x x y y f x, y dxdy
p q
Hu由正规化中心矩给出七个矩不变量,它们对于平 移、缩放、镜像和旋转具有不变性。 这七个矩不变量由三阶和二阶正规化中心矩得到:
连通成分标记的顺序算法
Algorithm 2.2: Sequential connected components algorithm using 4‐ connectivity 1. Scan the image left to right, top to bottom. 2. If the pixel is 1, then (a) If only one of its upper and left neighbors has a label, then copy the label. (b) If both have the same label, then copy the label. (c) If both have different labels, then copy the upper’s label and enter the labels in the equivalence table as equivalent labels. (d) Otherwise assign a new label to this pixel and enter this label in the equivalence table. 3. If there are more pixels to consider, then go to step 2. 4. Find the lowest label for each equivalent set in the equivalence table. 5. Scan the picture. Replace each label by the lowest label in its equivalent set.
M 1 20 02
面积和周长
面积等于连通成分 S 中像素的个数。对多个连通成 分,每个面积可以在连通成分标记算法中计算。 连通成分的周长存在着不同的定义: 分开 S 中像素和 S 中像素的“裂纹”长度之和; 边缘跟踪算法执行的跟踪步数; S 中边缘像素的个数。
紧密度
紧密度满足等周不等式:

P 4 A
2
3
2013/10/19
投影
二值图像在某直线上的投影:首先将直线分成若干 个箱体,然后计算图像中垂直某个箱体直线上取值 为 1 的像素数目。 投影是图像的紧凑表达,在投影中包含许多有用的 图像信息。 二值图像和二值图像投影之间不是一一对应的。 水平投影 Hi 和垂直投影 V j 分别为:
尺度滤波器
使用阈值化得到二值图像是非常通用的方法。 二值图像中有些区域是因为噪声产生的,通常情况 下这些区域尺度较小。 尺度滤波器将除去尺度小于T0 的所有成分。
欧拉数
欧拉数定义为连通成分数目减去孔数目:E = C – H 欧拉数是一个简单的拓扑特征,对平移、旋转和缩 放变换具有不变性。
2
假设 f x, y 是二维空间连续图像函数,则 p q 阶 矩为
m pq
x , y

x p y q f x, y dxdy
圆是最紧密的形状。 在许多应用中,这个比值用于区域特征。
其中: p, q 0,1, 2, m pq 由 f x, y 唯一确定,反之,f x, y 也可由 m pq 来 确定。
6
2013/10/19
区域边缘
连通成分 S 的边缘是 S 中与 S 邻接的像素集合。 通常以顺时针序列来跟踪区域的边缘像素。
Algorithm 2.3: Boundary‐following algorithm 1. 2. 3. 4. 5. Find the starting pixel s S for the region using a systematic scan, say from left to right and from top to bottom of the image. Let the current pixel in boundary tracking be denoted by c. Set c = s and let the 4‐neighbor to the west of s be bS . Let the eight 8‐neighbors of c starting with b in clockwise order be n1, n2,…, n8. Find ni, for the first i that is in S. Set c = ni and b = ni‐1. Repeat steps 3 and 4 until c = s.
二值化
MATLAB相关操作
读图像文件:img = imread(filename, fmt) 写图像文件:imwrite(img, filename, fmt) 显示图像:imshow(img) 计算并显示图像灰度直方图:imhist(img) 使用Otsu方法计算阈值:level = graythresh(img) 二值化:BWimg = im2bw(img, level)
2
yij FT i, j b i 0 j 0 xij
m 1 n 1 m 1 n 1 2
FT i, j c i 0 j 0 yij x' x x y' y y
cos 2
ac b 2 a c
2013/10/19
主要内容
二值图像形成 几何性质 拓扑性质 二值图像中物体识别
第二讲 二值图像处理
图像分割
机器视觉最重要的问题之一是标记物体子图像; 标记物体的操作对人类容易对计算机难; 区域是图像的一个子集(子图像); 将图像像素分割为区域的过程称为图像分割,是图 像理解中非常重要的一个步骤。
相关主题