Download presentation
Presentation is loading. Please wait.
Published byMarilynn Hart Modified over 9 years ago
1
Digital Topology CIS 601 Fall 2004 Longin Jan Latecki
2
Relationship between pixels Neighbors of a pixel – 4-neighbors (N,S,W,E pixels) == N 4 (p). A pixel p at coordinates (x,y) has four horizontal and vertical neighbors: (x+1,y), (x-1, y), (x,y+1), (x, y-1)
3
– You can add the four diagonal neighbors to give the 8- neighbor set. Diagonal neighbors == ND(p). – 8-neighbors: include diagonal pixels == N 8 (p).
4
Pixel Connectivity Connectivity is used to trace contours, to define object boundaries, and for segmentation. In order for two pixels to be connected, they must be “neighbors” sharing a common property—satisfy some similarity criterion. In a binary image with pixel values “0” and “1”, two neighboring pixels are said to be connected if they have the same value. Let V: Set of binary or gray level values used to define connectivity; e.g., V={1}.
5
Connectivity 4-adjacency: Two pixels p and q with values in V are 4-adjacent if q is in the set N 4 (p). 8-adjacency: q is in the set N 8 (p). A 4 (8)-path from p to q is a sequence of points p=p 0, p 1, …, p n =q such that each p n+1 is 4 (8)-adjacent to p n
6
Connected components Let S represent a subset of pixels in an image. Set S is connected if for each pair of points p and q in S, there is a path from p to q contained entirely S. A connected component is a maximal set of pixels in S that is connected. There can be more than one such set within a given S.
8
We assume that points r and t have been visited and labeled. Now we visit point p:p=0: no action; p=1: check r and t. – both r and t = 0; assign new label to p; – only one of r and t is a 1. assign its label to p; – both r and t are 1: same label => assign it to p; different label=> assign one of them to p and establish equivalence between labels (they are the same.) Second pass over the image to merge equivalent labels. r pt 4-connected component labeling for points
9
Homework 9 Develop a similar algorithm for 8-connectivity. Matlab example: BW = logical([1 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0]); L = bwlabel(BW,4); [r,c] = find(L == 2);
10
Problems with 4- and 8-connectivity Neither method is satisfactory. – Why? A simple closed curve divides a plane into two simply connected regions. – However, neither 4-connectivity nor 8-connectivity can achieve this for discrete labeled components. – Give some examples.
12
Border following Let our object b be an 8-connected set of 1’s that is not a single isolated point. A pixel P is a border pixel of b if P is 4-adjacent to at least one 0. Let the 8 neighbors of P be ordered counterclockwise as follows, which implies that the outer border will be followed counterclockwise. N4N3N2 N5 PN1 N6N7N8
13
Border following algorithm: Let (P_i,Q_i) be such that P_i is in b (P_i is 1), Q_i is 0, Q_i = N_1, and P_i and Q_i are 4-adjacent. Then P_i+1 = N_k, where N_k is the first of the 8 neighbors of P_i that is 1 (it exists since b is not a single isolated point) and Q_i = N_k-1. The algorithm stops when we come back to the initial point pair (P_1, Q_1). This stop condition is necessary, since we can pass through a point twice (give an example). In Matlab use function B = boundaries(BW);
14
Q3 Q41 P31 P2Q2 1 P411 P1Q1 Q51 P51 P61 P7 Q6Q7 Example of the border following algorithm:
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.