Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng.

Similar presentations


Presentation on theme: "1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng."— Presentation transcript:

1 1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng Chapter 12: Shapes and Boundaries

2 2 © 2010 Cengage Learning Engineering. All Rights Reserved. 12.1 Introduction How do we tell if two objects have the same shape? How can we classify shape? How can we describe the shape of an object? Formal means of describing shapes are called shape descriptors, which may include size, symmetry, and length of perimeter Ch12-p.355

3 3 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. The idea of a chain code is quite straightforward: We walk around the boundary of an object, taking note of the direction we take The resulting list of directions is the chain code Ch12-p.355

4 4 FIGURE 12.2 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.356

5 5 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Suppose we walk along the boundary in a counter- clockwise direction starting at the leftmost point in the top row and list the directions as we go 3 3 3 2 3 3 0 0 0 1 0 1 1 1 2 1 2 2 6 6 5 6 6 0 0 0 1 2 2 2 3 4 4 Ch12-p.356

6 6 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. A simple boundary-following algorithm has been given by Sonka et al. [35] The version for 4-connected boundaries: Start by finding the pixel in the object that has the left-most value in the topmost row; call this pixel P 0 Define a variable dir (for direction), and set it equal to 3 Ch12-p.357

7 7 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Traverse the 3 × 3 neighborhood of the current pixel in a counterclockwise direction, beginning the search at the pixel in direction This simply sets the current direction to the first direction counterclockwise from dir : Ch12-p.357

8 8 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. The first foreground pixel will be the new boundary element. Update dir Stop when the current boundary element P n is equal to the second element P 1 and the previous boundary pixel P n−1 is equal to the first boundary element P 0 im is a binary image Ch12-p.357

9 9 FIGURE 12.4 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.358

10 10 FIGURE 12.5 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.360

11 11 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.360

12 12 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.362

13 13 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.363

14 14 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. 12.2.1 Normalization of Chain Codes There are two problems with the definition of the chain code as given in previous sections: The chain code is dependent on the starting pixel The chain code is dependent on the orientation of the object. Ch12-p.363

15 15 FIGURE 12.7 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.364

16 16 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.363

17 17 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.364

18 18 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.365

19 19 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.365

20 20 FIGURE 12.8 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.366

21 21 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. 12.2.2 Shape Numbers We now consider the problem of defining a chain code that is independent of the orientation of the object Ch12-p.366

22 22 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.366

23 23 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Suppose we rotate the shape so that it has a different orientation (we use the rot90 function, which rotates a matrix by 90°) Ch12-p.367

24 24 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.367

25 25 FIGURE 12.9 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.368

26 26 FIGURE 12.10 © 2010 Cengage Learning Engineering. All Rights Reserved. (normalized) Ch12-p.369

27 27 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.369

28 28 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. This is already normalized Ch12-p.369

29 29 12.2 Chain Codes and Shape Numbers © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.370

30 30 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. The idea is this: suppose we walk around an object, but instead of writing down the directions, we write down the boundary coordinates The final list of (x, y) coordinates can be turned into a list of complex numbers z = x + yi The Fourier transform of this list of numbers is a Fourier descriptor of the object Ch12-p.371

31 31 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. We can easily modify our function chaincode4.m to boundary4.m by replacing the lines Ch12-p.371

32 32 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.371

33 33 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.372

34 34 FIGURE 12.11 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.372

35 35 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.373

36 36 FIGURE 12.12 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.373

37 37 12.3 Fourier Descriptors © 2010 Cengage Learning Engineering. All Rights Reserved. The Fourier transform of c contains only three nonzero terms Only two terms of the transform are enough to begin to get some idea of the shape, size, and symmetry of the object Even though the shape itself has been greatly hanged—a square has become a circle—many shape descriptors are still little changed (such as size and symmetry) Ch12-p.373

38 38 FIGURE 12.13 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.374

39 39 FIGURE 12.14 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.374

40 40 FIGURE 12.14 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch12-p.375


Download ppt "1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng."

Similar presentations


Ads by Google