290 likes | 320 Views
Digital Image Processing Lecture 13: Image Topology - Skeletonization April 14, 2005. Prof. Charlene Tsai. Before Lecture …. The venue for exam: 共同教室 106. Assisting materials (maybe): Calculator Breakfast & drinks Prohibited items: Cell phone. Introduction.
E N D
Digital Image Processing Lecture 13: Image Topology - SkeletonizationApril 14, 2005 Prof. Charlene Tsai
Before Lecture … • The venue for exam: 共同教室106. • Assisting materials (maybe): • Calculator • Breakfast & drinks • Prohibited items: • Cell phone Lecture 1
Introduction • Skeleton of a binary object: a collection of lines and curves whichencapsulate the size/shape of the object. • Application example: hand gesture recognition Lecture 1
Application Example • Application example: handwriting digits recognition Lecture 1
Application Example • Application example: human body analysis video image motion detection skeleton Lecture 1
What is a skeleton? • A skeleton can be defined by medial axis of an object:a pixel is on the medial axis if is equidistant from at least two pixels on the boundary of the object. • Methods of approaching the medial axis: • Imagine the object to be burning up by a fire which advances at a constant rate from the boundary. The places where two lines of fire meet form the medial axis. • Consider the set of all circles lying within the object which touch at least two points on the boundary. The centres of all such circles form the medial axis. Lecture 1
Topological Methods • We can directly define those pixels which are to be deleted to obtain the final skeleton. • In general, we want to delete pixels which can be deleted without changingthe topology of an object: • i.e., the number of components, the number of holes, or the relationship of objects and holes unchanged Example 1 A non-deletable pixel: creates a hole Lecture 1
More Examples Example 2 A non-deletable pixel: removes a hole Example 3 A non-deletable pixel: disconnects an object Lecture 1
More Example Neither 4-simple Nor 8-simple 8-simple Not 4-simple • 4-simple: A pixel which can be deleted without changing the 4-connectivity of the object; • 8-simple: A pixel which can be deleted without changing the 8-connectivity of the object. Example 4 A non-deletable pixel: 4-connectivity 8-connectivity 4-connectivity Lecture 1
Check for Deletability of a Pixel • A pixel’s deletability can be tested by checking its 3x3 neighbourhood. • For this example, checking the deletability of the central pixel: • The top two pixels and the bottom two pixels become separated, thus breaking up the object. • The top two pixels and the bottom two pixels are joined by a chain of pixels outside the neighbourhood, i.e, all pixels will encircle a hole, and removing the central pixel will remove the hole Lecture 1
(con’d) • To check whether a pixel is 4-simple or 8-simple, introduce some numbers associated with the neighbourhood of a foreground pixel • Define Np : the 3x3 neighbourhood of p, Np* : the 3x3 neighbourhood excluding p • Then, • A(p): the number of 4-components in Np* • C(p): the number of 8-components in Np* • B(p): the number of foreground pixels in Np* A(p) = 2 C(p) = 1 B(p) = 5 A(p) = 2 C(p) = 2 B(p) = 4 Lecture 1
•• o • • • o o • •• o • • • o o • (con’d) C(p)=1 A(p)=2 The importance of simple points for deletion: A foreground pixel p is 4-simple iff A(p)=1, and is 8-simple iff C(p)=1 • Since C(p)=1 the central pixel is 8-simple and so can be deleted without affecting the 8-connectivity of the object. • But since A(p)~=1, the central pixel is not 4-simple and so cannot be deleted without affecting the 4-connectivity of the object. •• o • • • o o • Lecture 1
Calculating A(p) and C(p) • For A(p) we are only interested in the case where A(p)=1 and this can be determined by calculating the crossing number X(p) of a foreground pixel • The crossing number X(p) of a foreground pixel p is defined to be the number of times a 0 is followed by a 1 as we traverse the 8-neighbours of p in a clockwise direction • If X(p) =1, then A(p)=1 and so p is 4-simple p1p2p3 p8pp4 p7p6p5 p1, p2, p3, p4, p5, p6, p7, p8, p1 • 1 0 • 0 p 0 • 0 1 1 X(p)=2 1, 1, 0, 0, 1, 1, 0, 0, 1 Lecture 1
1 0 • 1 P 1 • 0 0 1 1, 1, 0, 1, 1, 0, 0, 1, 1 • 1 1 • 1 P 1 • 1 0 0 1, 1, 1, 1, 0, 0, 1, 1, 1 • 1 1 • 0 P 0 • 1 0 1 1, 1, 0, 0, 1, 0, 1, 0, 1 More Practice on Calculating A(p) X(p)=2 X(p)=1 X(p)=3 Lecture 1
•• o o • o o •• •• o • • • o o • Calculating C(p) p1p2p3 p8pp4 p7p6p5 Lecture 1
How not to do skeletonization • In general, a skeletonization algorithm works by an iteration process: at each step identifying deletable pixels, and deleting them. The algorithm will continue until no further deletions are possible. • One way to remove pixels: • At each step, find all foreground pixels which are 4-simple, and delete them all. BUT…. 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 They are all 4-simple ! Deleting them all will thus remove the object completely. Lecture 1
Zhang-Suen Skeletonization Algorithm • An extra test for deletability needed to avoid deleting too many pixels. • Two options: • Subiteration: providing a step-wise algorithm, which changes the test for deletability at each step • Subfield: applying a different test for deletability according to where the pixel lies on the image grid. • Z-S algorithm (subiteration) • For odd iterations, delete only pixels which are on the right hand side, or bottom of an object, or on a north-west corner. • For even iterations, delete only pixels which are on the left hand side, or top of an object, or on a south-east corner. Lecture 1
Zhang-Suen Algorithm • Step N • Flag a foreground pixel p=1 to be deletable if • 2B(p)6 • X(p)=1 • If N is odd, then • p2 p4 p6 = 0 • p4 p6 p8 = 0 • 4. If N is even, then • p2 p4 p8 = 0 • P2 p6 p8 = 0 If N is odd, then p4=0, or p6=0, or p2=p8=0 If N is even, then p2=0, or p8=0, or p4=p6=0 p1p2p3 p8pp4 p7p6p5 Delete all fagged pixels. Continue until there are no more deletable pixels in two successive iterations. Lecture 1
Example • Step 1 If N is odd, delete only pixels with bg pixels (1) on the right hand side, or (2) bottom of an object, or (3) on a north-west corner The boxed pixels show those which will be deleted by steps 1 Lecture 1
Example (con’d) • Step 2 If N is even , delete only pixels with bg pixels (1) on the left hand side, or (2) top of an object, or (3) on a south-east corner. Lecture 1
Example (con’d) Skeleton: the unboxed foreground pixels in the right hand diagram Lecture 1
How about this one? The algorithm is not flawless!!! Lecture 1
Guo-Hall Skeletonization • An example of subfield algorithm. • Method: • Imagining image grid labeled with 1s and 2s in a chessboard configuration: • Alternating between pixels labeled 1 and pixels labeled 2 from step to step until no more deletions. • For a foreground pixel in consideration, if C(p)=1 and B(p)>1, flag it as deletable. … … … … … Lecture 1
Example Step 1: C(p)=1 B(p)>1 Lecture 1
Example (con’d) Step 2: C(p)=1 B(p)>1 ? Lecture 1
Distance Transform Skeletonization • Review: what is distance transform? • How can it achieve skeletonization? • Apply the distance transform to the image negative • The skeleton consists of those pixel(i,j) for which Lecture 1
Aside … • Any other applications for distance transform? Lecture 1
Summary • Concept of skeletonization • Few algorithms: • Zhang-Suen • Guo-Hall • Distance transform Lecture 1