Vous êtes sur la page 1sur 11

4/28/2008

Pixel Relationships

ND(p)

N8 ( p ) = N D ( p ) N 4 ( p )

A pixel has four horizontal and vertical neighbors

and four diagonal neighbors

Some of the neighbors may fall outside the image if p is on the border of the image
copyright 2002H. R. Myler

m-Connectivity 0 1 1 0 1 0 0 0 1
4-connected

0 1 1 0 1 0 0 0 1
8-connected

0 1 1 0 1 0 0 0 1
m-connected

V set of intensity values used to define connectivity. In binary images, V = {1} refers to connectivity of pixels with value 1. g , { } y p

Two pixels, p and q, with values from V are m-connected if:

(i) q is in N4(p) or (ii) q is in ND(p) and N4(p) N4(q) is empty.


copyright 2002H. R. Myler

4/28/2008

A (digital) path (or curve) from pixel p with coordinates (x,y) to pixel q with coordinates (s,t) is a sequence of distinct pixels with coordinates
( x0 , y0 ), ( x1 , y1 ),...( xn , yn )

( x0 , y0 ) = ( x, y ) and ( xn , yn ) = ( s, t ) where and pixels ( xi , yi ) and ( xi +1 , yi +1 ) are connected for 1 i n In this case, n is the length of the path.

If ( x0 , y0 ) = ( xn , yn ) the path is a closed path. We can define 4-, 8-, or m-paths depending on type of connectivity specified: path b t ti it ifi d th between t right and top i ht d bottom right pixels are 8paths and m-path (previous slide)

copyright 2002H. R. Myler

If S is a subset of pixels in am image, two pixels p and q are said to be connected in S if there is a path between them consisting entirely of pixels in S. For any p in S, the set of pixels that are connected to it in S S is called a connected component of S. if it only has one connected component, then set S is called a connected set.

copyright 2002H. R. Myler

4/28/2008

Let R be a subset of pixels in an image. We call R a region of the image if R is connected set. Two regions Ri and Rj are called adjacent if their union forms a connected set. Regions that are not adjacent, are called disjoint.
Adjacent only if 8-connectivity is used! A 4-path does not exist.

Suppose that an image has K disjoint regions Rk, k = 1,K, none of which touches the image border. Let Ru is the union of all the K regions and (Ru)c its complement (complement of points S are points that are not S). We call Ru the foreground; (Ru)c the background.
copyright 2002H. R. Myler

The boundary (border or contour) of a region R is the set of points that are adjacent to points in the complement of R. In other words, the border of a region is the set of pixels in the th region th t h i that have at l t least one b k t background neighbor. d i hb Not a member of the border of the 1-valued region if 4connectivity is used between the region and its background.

Usually, 8y connectivity is used when talking about boundary

copyright 2002H. R. Myler

4/28/2008

Component Labeling
Scan image, left to right and examine all pixels that meet the membership requirement (value u set, V). ) If you seek 4-connected components: b

Examine each pixel along with its previously scanned 4-neighbors. If pV, then assign a new label to p if u and b are not in pV V or assign p the same label as u or b if one of them is not in V. Otherwise, choose a label between u and b and note that the labels are equivalent. copyright 2002H. R. Myler 7

Fundamental Questions we want to ask about Pixels Is pixel a equivalent to pixel b? Is pixel a in the same set as pixel b? Is pixel a connected to pixel b?

copyright 2002H. R. Myler

4/28/2008

Clustering
Clustering is the process of counting and labeling of objects within an image. Clusters consist of pixel groupings that are related to one another by a predetermined measure. This measure can be defined as a distance between clusters or a similarity measure such as pixel value, or it may be a complex set of identifiers and constraints that define membership in a cluster. The cluster may ultimately be mapped into a binary image as a unique object.
copyright 2002H. R. Myler

One of the simplest approaches is to specify a size in pixels (count) that the clusters should be. If we assume a binary image, the clustering algorithm processes each pixel and when one is found that is nonzero, it becomes part of the first cluster and is marked. The next nonzero pixel found is tested to see if the distance between it and the previous pixel is less than or equal to the desired cluster pixel size. If it is, it is marked as a member of the first cluster and the search continues. If it is not, it becomes the first member of the second cluster and is marked accordingly. This process continues until all pixels have been evaluated.
copyright 2002H. R. Myler

10

4/28/2008

The example shows a set of similar-sized objects that have been labeled by grayscale value:

copyright 2002H. R. Myler

11

Algorithm
i,j,k n Image[][] Num_of_Rows Num_of_Cols clustx[] clusty[] new_clust edist clust_size Loop variables. Cluster count variable. 2-D array containing binary image. Rows in Image Columns in Image Temporary storage for x-coordinate of last pixel in cluster []. See clustx. Flag for new cluster. Euclidean distance. Size of clusters to be found.

copyright 2002H. R. Myler

12

4/28/2008

At the completion of the function, the Image array contains pixel values that reflect their membership in the clusters found that meet the criteria of being g clust_size apart. Clusters of pixels that are larger than clust_size size will be partitioned into pieces as they are found in the image.

copyright 2002H. R. Myler

13

/* Cluster Analysis Function */ cluster() { int n, i, j, k; /* initialize cluster count variable n */ n=0; /* double-loop through each pixel of binary image */ for(i=0; i < Num_of_Rows; ++i) for(j=0; j < Num_of_Cols; ++j) if(n==0){ /* only do for 1st cluster */ if(Image[i][j] !=0){ n=1; /* 1st cluster found */ / /* store X coord. */ / clustx[1] = j; /* store y coord. */ clusty[1] = i; /* mark pixel as cluster 1 */ Image[i][j] = 1; } }
copyright 2002H. R. Myler

14

4/28/2008

/* test for membership in all known clusters */ else if(Image[i][j] != 0){ /* marker for new cluster */ new_clust = 0 /* compute Euclidean distance */ for(k = 1; k <= n; ++k){ edist = SQRT((j-clustx[k])2+(i-clusty[k])2); /* test against cluster size desired */ if(edist <= clust_size){ ( ){ /* set pixel to cluster number **/ Image[i][j] = k; new_clust = 1; k = n + 1; } } /* add a new cluster */ if(new_clust == 0 AND n <= 255){ n = n + 1; clustx[n] = x; [ ] ; clusty[n] = y; Image[i][j] = n; } } } }

copyright 2002H. R. Myler

15

Distance Measures
For pixels p, q, and z, with coordinates (x,y), (s,t) and (u,v), (x y) (s t) (u v) D is a distance function or metric if: a) D(p,q) 0 (D(p,q) = 0 iff p = q), b) D(p,q) = D(q,p) and c) D(p,z) D(p,q) + D(q,z)
p q
copyright 2002H. R. Myler

z 16

4/28/2008

euclidean
De (p,q) = [(x-s)2 + (yt)2]1/2

city-block
D4 (p,q) = | x-s| + |y-t|

checkerboard
D8 (p,q) = max(| x-s| , |yt|)
copyright 2002H. R. Myler

17

Arithmetic Operations

Pixel by Pixel +, -, and /.

copyright 2002H. R. Myler

18

4/28/2008

Addition

copyright 2002H. R. Myler

19

Subtraction

- 25 =

copyright 2002H. R. Myler

20

10

4/28/2008

Not

copyright 2002H. R. Myler

21

11

Vous aimerez peut-être aussi