SHAPE ANALYSIS INEL 6088 Computer Vision Refs.: ch. 6, Davies; Ch. - - PowerPoint PPT Presentation

shape analysis
SMART_READER_LITE
LIVE PREVIEW

SHAPE ANALYSIS INEL 6088 Computer Vision Refs.: ch. 6, Davies; Ch. - - PowerPoint PPT Presentation

SHAPE ANALYSIS INEL 6088 Computer Vision Refs.: ch. 6, Davies; Ch. 2 Jain et al. TOPICS Connected components CC Labeling Image moments Geometrical properties: position and orientation Region-boundary following Algorithm


slide-1
SLIDE 1

SHAPE ANALYSIS

INEL 6088 Computer Vision

Refs.: ch. 6, Davies; Ch. 2 Jain et al.

slide-2
SLIDE 2
  • Connected components
  • CC Labeling
  • Image moments
  • Geometrical properties: position and
  • rientation
  • Region-boundary following Algorithm
  • Distance-metrics and skeleton
  • Morphological operations

TOPICS

slide-3
SLIDE 3

DEFINITIONS

4-neighbors 8-neighbors

Foreground S: set of all1- pixels A pixel p in S is connected to another pixel q in S if there is a path from p to q consisting only

  • f 1-pixels in S.

connected component: set

  • f pixels in which all pixels are

connected to all other pixels.

Examples of a 4-path and an 8-

  • path. A path is a sequence of pixel

indices such that the pixels are neighbors. Ref: connected components: sec. 3.3.4 Szelinski

slide-4
SLIDE 4

DEFINITIONS

S: complement of S background: set of all connected components of S that have points in the border of an image. holes: components of S that are not background.

Ref: connected components: sec. 3.3.4 Szelinski

4-neighbors 8-neighbors

Examples of a 4-path and an 8-

  • path. A path is a sequence of pixel

indices such that the pixels are neighbors.

slide-5
SLIDE 5

Ambiguous!

If 1’s are connected they should isolate the 0 Use 8-connectivity for the foreground and 4-connectivity for the background

  • r vice versa.

Boundary S’’: set of pixels in S that have neighbors in S Interior: set of pixels in S that are not in S’’ Surroundings T of region S: any 4-path from a pixel in S to the border of the image must intersect T

slide-6
SLIDE 6

CONNECTED COMPONENT (OBJECT) LABELING

Recursive algorithm:

  • 1. Scan the image to find an unlabelled 1 pixel and

assign it a new label L

  • 2. Recursively assign a label L to all its 1 neighbours
  • 3. Stop if there are no more neighbouring un-labeled 1

pixels

  • 4. Go to step 1
slide-7
SLIDE 7

Sequential Algorithm

  • 1. Scan image left-to-right, top-to-bottom
  • 2. If a pixel is 1,

a) if only one of its upper or left neighbours has a label, or if both have the same label, copy the label b) if both have different labels, copy the upper’s label and enter the labels as equivalent in the equivalence table c) otherwise, assign a new label to this pixel

  • 3. Repeat step 2 until there are no more pixels to

consider

  • 4. Eliminate equivalent labels (see tables 6.1 - 6.5 in

Jain et.al. for an example)

slide-8
SLIDE 8

6.3 Object Labeling and Counting 165

4 4 4 4 4 3 4 3 3 3 3 1 3 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 2 1 2 2 5 6 5 7 7 8 8 6 5 7 7 8 8 6 5 7 7 8 6 5 5 7 7 Figure 6.5 Solving the labeling problem in a more complex case.

using a minimum rather than a maximum labehng convention, so that the values are in general sUghtly closer to the eventual ideal labels. (This also serves to demonstrate that there is not just one way of designing a suitable labeling algorithm.) The algorithm itself indicates that the coexist table should now appear as in Table 6.1. However, the whole process of calculating ideal labels can be made more efficient by inserting numbers instead of ticks, and also adding the right numbers along the leading diagonal, as in Table 6.2. For the same reason, the numbers below the leading diagonal, which are technically redundant, are retained here. The next step is to minimize the entries along the individual rows of the table, as in Table 6.3; next we minimize along the individual columns (Table 6.4); and then we minimize along rows again (Table 6.5). This process is iterated to completion, which has already happened here after three stages of minimization. We can now read off the final result from the leading diagonal. Note that a further stage of computation is needed to make the resulting labels consecutive integers, starting with unity. However, the procedure needed to achieve this is much more basic and does not need to manipulate a 2-D table of data. This will be left as a simple programming task for the reader. At this point, some comment on the nature of the process described above will be appropriate. What has happened is that the original image data have effectively been condensed into the minimum space required to express the

See textbook by Davies

slide-9
SLIDE 9

1 66 CHAPTER 6 Binary Shape Analysis

Table 6.1 Coexist table for the image of Fig. 6.4*

V V V V

*The ticks correspond to clashes of labels. Table 6.2 Coexist table with additional numerical information* 1 2 3 4 5 6 7 8 1 1 1 1 2 1 2 3 1 3 3 4 3 4 5 5 5 6 6 6 7 5 7 7 8 6 7 8 *This coexist table is an enhanced version of Table 6.3. Technically, the numbers along, and below, the leading diagonal are redundant, but nevertheless they speed up the subsequent computation. Table 6.3 Coexist table redrawn with minimized rows. At this stage the table is no longer symmetrical 1 3 1 3 5 5 6 6 5 5 6 6 5 6

slide-10
SLIDE 10

1 66 CHAPTER 6 Binary Shape Analysis

Table 6.1 Coexist table for the image of Fig. 6.4*

V V V V

*The ticks correspond to clashes of labels. Table 6.2 Coexist table with additional numerical information* 1 2 3 4 5 6 7 8 1 1 1 1 2 1 2 3 1 3 3 4 3 4 5 5 5 6 6 6 7 5 7 7 8 6 7 8 *This coexist table is an enhanced version of Table 6.3. Technically, the numbers along, and below, the leading diagonal are redundant, but nevertheless they speed up the subsequent computation. Table 6.3 Coexist table redrawn with minimized rows. At this stage the table is no longer symmetrical 1 3 1 3 5 5 6 6 5 5 6 6 5 6

6.3 Object Labeling and Counting 1 67

Table 6.4 Coexist table redrawn again with minimized columns

1 2 3 4 5 6 7 1 1 1 1 1 1 1 1 1 1

5 5 5 5 5 Table 6.5 Coexist table redrawn yet again with minimized rows. At this stage the table is in its final form and is once again symmetrical 1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 1 1 1 1 1 1 1 1 1 1

5 5 5 5 5

labels—namely, just one entry per original clash. This explains why the table retains the 2-D format of the original image: lower dimensionahty would not permit the image topology to be represented properly. It also explains why minimization has to be carried out, to completion, in two orthogonal directions. On the other hand, the particular implementation, including both above- and below-diagonal elements, is able to minimize computational overheads and finalize the operation in remarkably few iterations. Finally, it might be felt that too much attention has been devoted to finding connected components of binary images. This is a highly important topic in practical applications such as industrial inspection, where it is crucial to locate all the objects unambiguously before they can individually be identified and

  • scrutinized. In addition. Fig. 6.5 makes clear that it is not only U-shaped objects

that give problems, but also those that have shape subtleties—as happens at the left of the upper object in this figure.

slide-11
SLIDE 11

IMAGE MOMENTS AND GEOMETRICAL PROPERTIES

p+q order moments: 0-order moment = Area: 1st-order moment = position of centroid: For binary images B(i,j) = 1 for pixels in CC

mpq =

n

i=1 m

j=1

ipjqBij mpq =

n

i=1 m

j=1

Bij

¯ i = m10 m00 ¯ j = m01 m00

slide-12
SLIDE 12
  • rientation from 2nd & 1st order moments

a =

n

X

i=1 m

X

j=1

(i −¯ i)2B(i, j)

b = 2

n

X

i=1 m

X

j=1

(i −¯ i)(j − ¯ j)B(i, j) c =

n

X

i=1 m

X

j=1

(j − ¯ j)2B(i, j)

tan2θ = b a − c

90 − θ is the angle with horizontal axis

slide-13
SLIDE 13

SIZE FILTER

slide-14
SLIDE 14

ROW AND COLUMN PROJECTIONS

slide-15
SLIDE 15

EXAMPLE OF PROJECTIONS

slide-16
SLIDE 16
  • Col. Proj.

Row Proj.

The first moments of an image equal the first moments

  • f its projections!

ROW AND COLUMN PROJECTIONS

H[i] =

m−1

j=0

B[i, j] V[j] =

n−1

i=0

B[i, j]

slide-17
SLIDE 17

J=i= J=m-1 i=0 i=n-1 J=0 Affine transformation: Solve to get: d=0 d=n+m-2

Diagonal Projection

What’s the reason for the last one?

Binary image and its diagonal projection

slide-18
SLIDE 18

Image moments can be calculated (quickly) from the vertical, horizontal and diagonal projections (B.K.P. Horn, Robot Vision, MIT Press, 1986) defined as:

From these we can find the orientation:

slide-19
SLIDE 19

GENUS, OR EULER NUMBER
 TRANSLATION-, ROTATION- & SCALING-INVARIANT

E = C − H GENUS = Euler number: # connected components # holes

slide-20
SLIDE 20

Region boundary: Set of pixels of S that are adjacent to S

slide-21
SLIDE 21

Perimeter P: number of pixels in boundary. Can be computed by totaling the number of 0-valued 4- neighbors for each point. Compactness:

slide-22
SLIDE 22

RUN-LENGTH CODES

From these we can calculate the projections w/o generating the image, which in turn let us find the zero- first- and second-order moments and thus the orientation!

slide-23
SLIDE 23
slide-24
SLIDE 24

Distance metrics

q − − d4 = |xi − xj| + |yi − yj| = ( ) dE = q (xi − xj)2 + (yi − yj)2 | − | | − | d8 = max (|xi − xj|, |yi − yj|)

slide-25
SLIDE 25

Distance transform: provides the minimum distance from a pixel of an object to the background. To compute, use where m is the iteration number for all pixels [u,v] such that d([u,v],[i,j])=1. Use 4-neighbors.

slide-26
SLIDE 26

Skeleton S*

The set of locally maximum pixels of an

  • bject are the

skeleton, or medial axis. A pixel [i,j] is locally maximum if its distance to S is not closer than that of all its neighboring pixels [u,v]. Here we are using 4- neighbors.

slide-27
SLIDE 27

THINNING

slide-28
SLIDE 28

EXPANDING AND SHRINKING

Expanding: Change pixel from 0 to 1 if any neighbors of the pixel are 1. Shrinking: Change a pixel from 1 to 0 if any neighbors of a pixel are 0. Expanding followed by shrinking can be used to fill holes. Shrinking followed by expanding can remove isolated noise pixels.

slide-29
SLIDE 29