Digital Image Processing Lecture 13 Image Topology Skeletonization

  • Slides: 28
Download presentation
Digital Image Processing Lecture 13: Image Topology Skeletonization April 14, 2005 Prof. Charlene Tsai

Digital Image Processing Lecture 13: Image Topology Skeletonization April 14, 2005 Prof. Charlene Tsai Digital Image Processing Lecture 1

Before Lecture … § The venue for exam: 共同教室 106. § Assisting materials (maybe):

Before Lecture … § The venue for exam: 共同教室 106. § Assisting materials (maybe): § Calculator § Breakfast & drinks § Prohibited items: § Cell phone Digital Image Processing Lecture 1 2

Introduction § Skeleton of a binary object: a collection of lines and curves which

Introduction § Skeleton of a binary object: a collection of lines and curves which encapsulate the size/shape of the object. § Application example: hand gesture recognition Digital Image Processing Lecture 1 3

Application Example § Application example: handwriting digits recognition Digital Image Processing Lecture 1 4

Application Example § Application example: handwriting digits recognition Digital Image Processing Lecture 1 4

Application Example § Application example: human body analysis video image Digital Image Processing motion

Application Example § Application example: human body analysis video image Digital Image Processing motion detection Lecture 1 skeleton 5

What is a skeleton? § A skeleton can be defined by medial axis of

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. Digital Image Processing Lecture 1 6

Topological Methods § We can directly define those pixels which are to be deleted

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 changing the 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 Digital Image Processing Lecture 1 7

More Examples Example 2 A non-deletable pixel: removes a hole Example 3 A non-deletable

More Examples Example 2 A non-deletable pixel: removes a hole Example 3 A non-deletable pixel: disconnects an object Digital Image Processing Lecture 1 8

More Example Neither 4 -simple Nor 8 -simple Not 4 -simple 4 -connectivity 8

More Example Neither 4 -simple Nor 8 -simple Not 4 -simple 4 -connectivity 8 -connectivity 4 -connectivity Example 4 A non-deletable pixel: § 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. Digital Image Processing Lecture 1 9

Check for Deletability of a Pixel § A pixel’s deletability can be tested by

Check for Deletability of a Pixel § A pixel’s deletability can be tested by checking its 3 x 3 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 Digital Image Processing Lecture 1 10

(con’d) § To check whether a pixel is 4 -simple or 8 -simple, introduce

(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 3 x 3 neighbourhood of p, Np* : the 3 x 3 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 Digital Image Processing Lecture 1 11

(con’d) • • o • • • A(p)=2 o o • • • o

(con’d) • • o • • • A(p)=2 o o • • • o o • C(p)=1 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 • • o • • • o o • § 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. Digital Image Processing Lecture 1 12

Calculating A(p) and C(p) § For A(p) we are only interested in the case

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 p 1 p 2 p 3 p 8 p p 4 p 7 p 6 p 5 p 1, p 2, p 3, p 4, p 5, p 6, p 7, p 8, p 1 1 1 0 2 0 p 0 3 0 1 1 1, 1, 0, 0, 1 Digital Image Processing Lecture 1 X(p)=2 13

More Practice on Calculating A(p) 1 1 0 2 1 P 1 3 0

More Practice on Calculating A(p) 1 1 0 2 1 P 1 3 0 0 1 1, 1, 0, 0, 1, 1 1 2 1 P 1 3 1 0 0 1, 1, 0, 0, 1, 1, 1 X(p)=1 1, 1, 0, 0, 1, 0, 1 X(p)=3 1 1 1 2 0 P 0 3 1 0 1 Digital Image Processing Lecture 1 X(p)=2 14

Calculating C(p) p 1 p 2 p 3 p 8 p p 4 p

Calculating C(p) p 1 p 2 p 3 p 8 p p 4 p 7 p 6 p 5 • • o o • • • o o • Digital Image Processing Lecture 1 15

How not to do skeletonization § In general, a skeletonization algorithm works by an

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 Digital Image Processing 0 1 1 0 0 0 They are all 4 -simple ! Deleting them all will thus remove the object completely. Lecture 1 16

Zhang-Suen Skeletonization Algorithm § § An extra test for deletability needed to avoid deleting

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. Digital Image Processing Lecture 1 17

Zhang-Suen Algorithm Step N Flag a foreground pixel p=1 to be deletable if 1.

Zhang-Suen Algorithm Step N Flag a foreground pixel p=1 to be deletable if 1. 2 B(p) 6 If N is odd, then p 4=0, 2. X(p)=1 or p 6=0, or p 2=p 8=0 3. If N is odd, then p 2 p 4 p 6 = 0 p 4 p 6 p 8 = 0 If N is even, then p 2=0, 4. If N is even, then or p 8=0, or p 4=p 6=0 p 2 p 4 p 8 = 0 P 2 p 6 p 8 = 0 Delete all fagged pixels. Continue until there are no more deletable pixels in two successive iterations. Digital Image Processing Lecture 1 p 2 p 3 p 8 p p 4 p 7 p 6 p 5 18

Example § Step 1 If N is odd, delete only pixels with bg pixels

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 Digital Image Processing Lecture 1 19

Example (con’d) § Step 2 If N is even , delete only pixels with

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 southeast corner. Digital Image Processing Lecture 1 20

Example (con’d) Skeleton: the unboxed foreground pixels in the right hand diagram Digital Image

Example (con’d) Skeleton: the unboxed foreground pixels in the right hand diagram Digital Image Processing Lecture 1 21

How about this one? 0 0 0 1 1 0 0 0 The algorithm

How about this one? 0 0 0 1 1 0 0 0 The algorithm is not flawless!!! Digital Image Processing Lecture 1 22

Guo-Hall Skeletonization 1 2 2 1 … … … Lecture 1 2 1 …

Guo-Hall Skeletonization 1 2 2 1 … … … Lecture 1 2 1 … Digital Image Processing 1 2 … § An example of subfield algorithm. § Method: § Imagining image grid labeled with 1 s and 2 s 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. … … 23

Example Step 1: Digital Image Processing . . . 1 2 1 2 1

Example Step 1: Digital Image Processing . . . 1 2 1 2 1 . . . 2 1 2 1 2. . . 1 2 1. . . . . Lecture 1 C(p)=1 B(p)>1 24

Example (con’d) Step 2: ? Digital Image Processing . . . 2 1 2

Example (con’d) Step 2: ? Digital Image Processing . . . 2 1 2 . . 2. . . 2. 2. 1 2 1 2. . 2. 2 1 2 1. . . 2 1 2. 2. . Lecture 1 C(p)=1 B(p)>1 25

Distance Transform Skeletonization § Review: what is distance transform? § How can it achieve

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 Digital Image Processing Lecture 1 26

Aside … § Any other applications for distance transform? Digital Image Processing Lecture 1

Aside … § Any other applications for distance transform? Digital Image Processing Lecture 1 27

Summary § Concept of skeletonization § Few algorithms: § Zhang-Suen § Guo-Hall § Distance

Summary § Concept of skeletonization § Few algorithms: § Zhang-Suen § Guo-Hall § Distance transform Digital Image Processing Lecture 1 28