電腦視覺 Computer and Robot Vision I Chapter3 Binary Machine Vision: Region Analysis Instructor: Shih-Shinh Huang 1 Contents Region Properties Simple Global Properties Extremal Points Spatial Moments Mixed Spatial Gray Level Moments Signature Properties Contour-Based Shape Representation 2 Computer and Robot Vision I Introduction Region Properties 3 Region Properties Introduction Region Description Region is a segment produced by connected component labeling or signature segmentation. The computation of region properties can be the input for further classification. • Gray-Level Value Analysis • Shape Property Analysis 4 Region Properties Simple Global Properties Region Area A A 1 ( r ,c )R A=21 r=3.476 c=4.095 Centroid ( r , c ) 1 r r A ( r ,c )R 0 1 2 3 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 1 1 1 1 1 0 3 0 0 1 1 1 4 0 0 1 1 1 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 5 1 c c A ( r ,c )R 6 7 5 4 5 6 7 0 0 0 0 0 0 Region Properties Simple Global Properties Perimeter Description It is a sequence of its interior border pixels. Border pixels are the pixels that have some neighboring pixel outside the region. Types of Perimeter 4-Connected Perimeter P4: Use 8-Connectivity to determine the border pixel. 8-Connected Perimeter P8:Use 4-Connectivity to determine the border pixel. 6 Region Properties Simple Global Properties 4-Connected Perimeter P4 P44 {( {(r1,,c2)), ),8((2r, 2 2,3 P (R2,|1N c)),(R ),}(3,2)} (2,1) P4 7 (2,2) P4 Region Properties Simple Global Properties 8-Connected Perimeter P8 P88 {({(r1 ),R (2| ,1 ,2)} P , c,2 ) N), , c,3) ), (R3 } 4 ((r2 (2,1) P8 8 (2,2) P8 Region Properties Simple Global Properties Perimeter Representation P It is a sequences of border pixels in P (r0 , c0 ), (r1, c1 ),....(rK 1, cK 1 ) • (rk 1 , ck 1 ), (rk , ck ) • (r0 , c0 ) (rK 1 , cK 1 ) P4 are neighborhood P8 9 P4 or P8 Region Properties Simple Global Properties Perimeter Length | P | Vertical or Horizontal Line Diagonal Line | P4 | 8 | P8 | 4 2 10 Region Properties Simple Global Properties Compactness Measure | P |2 / A It is used as a measure of a shape’s compactness. Its smallest value is not for the digital circularity, but it would for continuous planar shapes • Octagons • Diamonds 11 Region Properties Simple Global Properties Circularity Measure R / R (r , c ) Boundary Pixels (r1 , c1 ) P (r0 , c0 ), (r1, c1 ),....(rK 1, cK 1 ) 1 R K 1 K 2 R (r0 , c0 ) K || (r , c k 0 k ) (r , c ) || k K || (r , c k 0 k (r2 , c2 ) k ) (r , c ) || R 2 12 (r3 , c3 ) Region Properties Simple Global Properties Circularity Measure R / R Properties • Digital shape circular, R / R increases monotonically. • It is similar for similar digital/continuous shapes • It is orientation and area independent. Polygon Side Estimation R N 1.41111 R 13 0.4724 Region Properties Simple Global Properties Gray-Level Mean 1 I (r , c) A ( r ,c )A Gray-Level Variance 1 1 2 2 2 I ( r , c ) I ( r , c ) A ( r ,c )A A ( r ,c )A 2 Right hand equation lets us compute variance with only one pass 14 Region Properties Simple Global Properties Microtexture Properties Co-occurrence Matrix P( g1 , g 2 ) P (.,.) # [(ri , ci ), (rj , c j )] S | I (ri , ci ) g1 , I (rj , c j ) g 2 #S • S : a set of all pairs of pixels that are in some defined spatial relationship (4-neighbors) 15 Region Properties Simple Global Properties 0 0 1 2 3 1 2 3 P (.,.) 0 P1,0 P0,1 P2,2 DC & CV Lab. 16 Region Properties Simple Global Properties Microtexture Properties Texture Second Moment M M 2 P ( g1 , g2 ) g1 , g 2 Texture Entropy E E P( g1 , g 2 ) log P( g1 , g 2 ) g1 , g 2 Texture Homogeneity H P( g1 , g 2 ) H g1 , g 2 k | g1 17g 2 | Region Properties Simple Global Properties Microtexture Properties Contrast C C 2 | g g | P ( g1 , g 2 ) 1 2 g1 , g 2 Correlation 2 ( g )( g ) P ( g , g ) / 1 2 1 2 g1 , g 2 18 Region Properties Extremal Points Definition of Extremal Points It has an extremal coordinate value in either its row or column coordinate position They can be as many as eight distinct extermal points. 19 Region Properties Extremal Points 20 Region Properties Extremal Points Different extremal points may be coincident 21 Region Properties Extremal Points Definition of Extremal Coordinate Topmost r1 r2 rmin min{r | (r, c) R} Bottommost r5 r6 rmax max{r | (r, c) R} Leftmost c7 c8 cmin min{c | (r, c) R} Rightmost c3 c4 cmax max{c | (r, c) R} Topmost Rightmost Leftmost Bottommost 22 Region Properties Extremal Points Definition of Extremal Coordinate Topmost Left (r1 , c1 ) {rmin , min{c | (rmin , c) R} Topmost Right (r2 , c2 ) {rmin , max{c | (rmin , c) R} Topmost Right Topmost Left 23 Region Properties Extremal Points Respective Axes (M1, M2, M3, M4) Form by each pair of opposite extremal points • M1: Topmost Left & Bottommost Right • M2: Topmost Right & Bottommost Left • M3: Rightmost Top & Leftmost Bottom • M4: Rightmost Bottom& Leftmost Top. Properties • Length • Orientation 24 Region Properties Extremal Points 25 Region Properties Extremal Points Length of Respective Axes M (ri rj ) 2 (ci c j ) 2 Q( ) Quantization Error Compensation Term (ri , ci ) : one end point of respective axes (rj , c j ): the other point of respective axes 26 Region Properties Extremal Points Orientation of Respective Axes Orientation of a line segment is taken as counterclockwise with respect to column axis. t an 1 (ri rj ) (ci c j ) Quantization Error Compensation Term 1 | cos | Q( ) 1 | sin | 27 | | 45 | | 45 Region Properties Extremal Points Properties of Line-like Region * M Major Axis : the axis with the largest length. M * max{M1, M 2 , M3 , M 4} The length and orientation of major axis stands for the same thing for this region. 28 Region Properties Extremal Points • Properties of Line-like Region M1, M 2, M3 M4 29 Region Properties Extremal Points Properties of Triangular Shapes Apex Selection: Find the extremal point having the greatest sum of its two largest distances. • Extremal Point Distance M ij (ri rj ) 2 (ci c j ) 2 • Objective Function (k1* , k2* , k3* ) argmax{M k1k2 M k1k3 } 30 Region Properties Extremal Points Properties of Triangular Shapes Side Length L L (M k1k2 M k1k 3 ) / 2 L h Base Length B B M k2k3 Altitude Height h B h L2 B / 2 2 31 Region Properties Extremal Points h B 32 Region Properties Spatial Moments Second-Order Spatial Moments Row Moment rr rr 1 (r r ) 2 A ( r ,c )R Mixed Moment rc rc 1 (r r )(c c ) A ( r ,c )R Column Moment cc cc 1 2 ( c c ) A ( r ,c )R 33 Region Properties Spatial Moments Second-Order Spatial Moments They have value meaning for a region of any shape Similarly, the covariance matrix has value and meaning for any two-dimensional pdf. Example: An ellipse A whose center is the origin. R {(r , c) | dr2 2erc fc 2 1} d e e cc 1 2 f 4( rr cc rc ) rc 34 rc rr Region Properties Mixed Spatial Gray Level Moments Description A property that mixes up two properties. • Spatial Properties: Region Shape, Position • Intensity properties Two Second-order Mixed Spatial Gray Properties rg 1 (r r )(I (r , c) ) A ( r ,c )R cg 1 (c c )(I (r , c) ) A ( r ,c )R 35 Region Properties Mixed Spatial Gray Level Moments Application: Determine the least-square, best-fit gray level intensity plane. I (r, c) (r r ) (c c ) Unknowns Variables: , , Objective Function (ˆ , ˆ , ˆ ) arg min 2 ( , , ) [ (r r ) (c c ) I (r, c)]2 36 Region Properties Mixed Spatial Gray Level Moments Application: Determine the least-square, best-fit gray level intensity plane Take partial derivative of 2 with respect to ( , , ) (ˆ , ˆ , ˆ ) arg min 2 ( , , ) (r r ) 2 ( r ,c )R (r r )(c c ) ( r ,c )R (r r ) ( r ,c )R (r r )(c c ) (r r ) (r r )(I (r , c)) ( r ,c )R ( r ,c )R ( r ,c )R 2 ( c c ) (c c ) (c c )(I (r , c)) ( r ,c )R ( r ,c )R ( r ,c )R ( c c ) 1 I ( r , c ) ( r ,c )R ( r ,c )R ( r , c ) R Least Square Method 37 Region Properties Mixed Spatial Gray Level Moments Application: Determine the least-square, best-fit gray level intensity plane 2 2 (r (rr) r ) (r (rr)(c r)(cc) c ) (0r r ) (r r()rI(rr,)( c)I (r , c)) ( r ,c )R( r ,c )R (r ,c )R( r ,c )R ( r ,c )R( r ,c )R ( r ,c )R 2 2 (r (rr)(c r)(cc) c ) ( c ( c c ) c ) ( 0 c c) (c c(c) I(rc,)( c)I(r , c)) ( r ,c )R( r ,c )R ( r ,c )R( r ,c )R ( r ,c )R( r ,c )R ( r ,c )R (r r0) I (r , c)I (r , c) 0 A ( c c ) 1 ( r , c ) R ( r , c ) R ( r , c ) R ( r , c ) R ( r , c ) R (r r ) 0 ( r ,c )R (c c ) 0 1 I (r , c) A ( r ,c )R ( r ,c )R 38 Region Properties Mixed Spatial Gray Level Moments 2 ( r r ) ( r r )( c c ) 0 ( r r ) I ( r , c ) 0 (rr ( r ,c )R rc rg r ,c )R ( r ,c )R 2 ( r r )( c c ) ( c c ) 0 ( c c ) I ( r , c ) 0 rc ( r ,c )R cg cc ( r ,c )R ( r ,c )R 0 A 0 A 0 0 I ( r , c ) ( r ,c )R rg cg rr rc rc cc rc cc rr rc rr rc 39 rg cg rc cc Computer and Robot Vision I Introduction Signature Properties 40 Signature Properties Introduction Signature Review Remark: Signature analysis is important because of easy, fast implementation in pipeline hardware 41 Signature Properties Signature Computation Centroid ( r , c ) r 1 1 1 1 r r r 1 rPH (r ) A ( r ,c )R A r {c|( r ,c )R} A r {c|( r ,c )R} A r c 1 1 1 1 c c c 1 cPV (c) A ( r ,c )R A c {r|( r ,c )R} A r {r|( r ,c )R} A r Second-Order Moment ( rr ) rr 1 1 2 ( r r ) (r r ) 2 A ( r ,c )R A r {c|( r ,c )R} 1 1 2 ( r r ) 1 (r r ) 2 PH (r ) A r A r {c|( r ,c )R} 42 Signature Properties Signature Computation Second-Order Moment ( cc ) cc 1 1 2 2 ( c c ) ( c c ) A ( r ,c )R A r {c|( r ,c )R} 1 1 2 2 ( c c ) 1 ( c c ) PV (c) A r A r {c|( r ,c )R} 43 Signature Properties Circle Center Determination Description We can determine the center position of circular region from signature analysis. cos y cos x | x | y x | y | 44 A B C D A B C D cos x cos y Signature Properties Circle Center Determination Derivation A B r r 2 A B A 1 2 1 r ( 2 ) rd sin 2 2 2 A 1 2 d r 2 2 sin 2 r A 1 2 r 2 2 cos sin 2 A 1 2 r 2 sin 2 2 45 Signature Properties Circle Center Determination Derivation r A A B 1 2 r 2 sin 2 2 2A 2 sin 2 A B Compute by a table-look-up technique d r cos A B cos 46 Circle Center Determination Algorithm Step 1: Partition the circuit into four quadrants formed by two orthogonal lines intersecting inside the circle. y x Step 2: Using signature analysis to compute the areas A, B, C, and, D. Step 3: Compute x, y using the derived equation. | x | 47 A B C D cos x Computer and Robot Vision I Introduction Contour-Based Shape Representation 48 Chain Code Description It describes an object by a sequence of unit-size line segment with a given orientation. The first element must bear information about its position to permit region reconstruction. Chain Code: 3, 0, 0, 3, 0, 1, 1, 2, 1, 2, 3, 2 49 Chain Code Matching Requirement It must be independent of the choice of the first border pixel in the sequence. It requires the normalization of chain code • Interpret the chain code as a base 4 number. • Find the pixel in the border sequence which results in the minimum integer number. Chain Code: (300301121232)4 Chain Code: (003011212323)4 50 Curvature Description Curvature is defined as the rate of change of slope in the continuous case. The evaluation algorithm in the discrete case is based on the detection of angles between two lines. Values of the curvature at all boundary pixels can be represented by a histogram for matching. 51 Curvature b: sensitivity to local changes. 52 Signature Description The signature is a sequence of normal contour distances. It can be calculated for each boundary elements as a function of the path length. 53 Chord Distribution Description Chord is a line joining any two points of the region boundary. The distribution of lengths and angles of all chords may be used for shape description. Definition of Chord Distribution b( x, y) 1 : contour points b( x, y ) 0 : all other points h(x, y) b(i, j )b(i x, j y) i j 54 Chord Distribution h(x, y) b(i, j )b(i x, j y) i j Rotation-Independent Radial Distribution /2 hr ( r ) h(x, y )rd /2 55 r x 2 y 2 sin 1 (y / r ) Segment Sequence Description It is a way to represent the boundary using segments with specified properties. Recursive Boundary Splitting 56 Segment Sequence Structure Description Curves are segmented into several types • Circular Arcs • Straight Line Segments are considered as primitives for syntactic shape recognition Chromosomes Representation. 57 Scale-Space Image Description Sensitivity of shape descriptors to scale (image resolution) is an undesirable feature. Some curve segmentation points exist in one resolution and disappear in others. Approach Properties Only new segmentation points can appear at higher resolution. No existing segmentation points can disappear. 58 Scale-Space Image Approach Description It is based on application of a unique Gaussian smoothing kernel to a one-dimensional signal. The zero-crossing of the second derivative is detected to determine the peak of curvature. The positions of zero-crossing give the positions of curve segmentation points. 59 Scale-Space Image 60 Computer and Robot Vision I The End 61