5 Industrial Vision Machine Vision Systems : Image Acquisition Image processing Analysis/Exploitation
5- Image processing Y (colomns) 35 3 38 3 5 35 69 8 3 38 3 3 69 79 39 3 3 33 9 37 6 77 X (rows) 7 38 3 39 3 8 56 53 58 9 5 55 88 3 8 8 65 73 55 5 5
5-3 Image processing Neighborhood and connexity y (x,y) (x,y) 38 63 7 55 f(x,y) 63 7 7 6 (x+,y) x 8-neighbors (x,y+) -neighbors
5- Image processing INPUT 3 3 5 5 5 5 5 5 5 5 5 5 5 5 Preprocessing (image enhancement) 5 5 5 5 5 5 5 5 5 5 Parameters extractioin 5 5 5 5 Segmentation 5 5 5 5 5 5 5 5 5 5
5-5 Image processing Image processing : Preprocessing (basic) Linear Filtering Non Linear Filtering
5-6 Basic Transformation Géométrical Vertical symetry Horizontal symetry Rotation - 9
5-7 Basic Transformation Arithmetic Input Image : E(x,y) Output Image : S(x,y) Input + Input -
5-8 Basic Transformation Arithmetic Input Image : E(x,y) Ouput Image : S(x,y) Input X,5 Input X,6
5-9 Basic Transformation Histogram modification H()= (,) y x 3 3 Histogram
5 Basic Transformation Histogram modification H()= (,) y x 3 3 Histogram
5 Basic Transformation Histogram modification H()= (,) y x 3 3 Histogram
5 Basic Transformation Histogram modification H()=3 (,) y x 3 3 Histogram
53 Basic Transformation Histogram modification H()= (,) y x 3 3 Histogram
5 Basic Transformation Histogram modification H()=5 (,) y x 3 3 Histogram
55 Basic Transformation Histogram modification H()=6 (,) y x 3 3 Histogram
56 Basic Transformation Histogram modification h() = 6 h() = 3 (,) x 3 3 Histogram h() = h(3) = h() = y PDF
57 Basic Transformation : Dynamic expansion 5 5 35 3 5 9 8 9 8 76 76 6 8 96 8 6 8 3 6 5 5 Niveau de Gris 8 6 Niveau de Gris 6 8 96 8 6 8 3 6 h(i) S(x,y) : [Smin, Smax] h(i) E(x,y) : [Emin, Emax] Histogram
58 Basic Transformation Histogram : Equalisation Flatten the histogram, «equiprobability of all level»
59 Basic Transformation Inversion Input Image : E(x,y) Output Image : S(x,y) S x, y =55 E x, y
5- Basic Transformation Thresholding Input Image : E(x,y) [, 55] Output Image : S(x,y) If E x, y T S x,y Else S x,y S(x,y) : [, ] T = 8
5- Basic Transformation Logical Operators A A A NOT A B B A AND B A OR B
5- Linear Filtering Convolution = Weighted sum over the Neighboring pixels n Ps x, y = m k i, j Pe x i, y j j= n i= m Kernel k : [ 3 x 3 ] Ps x, y = k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) k i, j Pe x i, y j j= i= k(,) 5 Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y+) Pe(x,y+) Pe(x+,y+) 85 8 8
5-3 Linear Filtering Kernal k : [ 3 x 3 ] Ps x, y = k i, j Pe x i, y j j= i= Switch the kernel coefficient around Center k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) 5 Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y+) Pe(x,y+) Pe(x+,y+) 85 8 Ps(x,y) = k(,) Pe(x+,y+) + k(,) Pe(x+,y) + k(,) Pe(x+,y+) +... 8
5- Linear Filtering Noyau k : [ 3 x 3 ] Ps x, y = k i, j Pe x i, y j j= i= k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) 5 Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y+) Pe(x,y+) Pe(x+,y+) 85 8 Ps(x,y) = k(,) Pe(x+,y+) + k(,) Pe(x+,y) + k(,) Pe(x+,y) k(,) Pe(x,y+) +... + k(,) Pe(x,y) + k(,) Pe(x,y) 8
5-5 Linear Filtering Noyau k : [ 3 x 3 ] Ps x, y = k i, j Pe x i, y j j= i= k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) k(,) 5 Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y) Pe(x,y) Pe(x+,y) Pe(x,y+) Pe(x,y+) Pe(x+,y+) 85 8 Ps(x,y) = k(,) Pe(x+,y+) + k(,) Pe(x+,y) + k(,) Pe(x+,y) k(,) Pe(x,y+) k(,) Pe(x,y+) + k(,) Pe(x,y) + k(,) Pe(x,y) + k(,) Pe(x,y) + k(,) Pe(x,y) 8
5-6 Linear Filtering Example : Symetric Kernel around Center k(,) Ps(x,y) = x 5 7 68 63 - - 69 6 55 58 5 5 - x 55 x 63 x 5 + x 6 x 68 x 58 - x 69 x 7 Ps(x,y) = 5
5-7 Linear Filtering Example : Laplacien [3 x 3] (edge detector) 9 8 =
5-8 Non Linear Filtering Order Filter, Median Filter = Order the neighboring pixels and take the median one [3x3] 3 3 5 8 7 5 5 7 36 3 8 8 57 8 8 5 5 3 36 8 57
5-9 Non Linear Filtering Median Filter, efficient for impulse noise
5-3 Non Linear Filtering Mathématical Morphology Non linear calculation on the neighborhood Can be used on binary or Gray level images Binary image application
5-3 Non Linear Filtering Erosion A B
5-3 Translation of A by x : x A = { a = (a, a ) / a, a Z } ( A) x = { c = a + x / a A} Complement of A : A = { x / x A} c
5-33 Returning of A (/from an origine): A = { a = (a, a ) / a, a Z } Aˆ = { c = a / a A}
5-3 Difference between A and B : A = { a = (a, a ) / a, a Z } A B = { b = (b, b ) / b, b Z } A B = { x Z / x A et x B} B
5-35 Erosion of A by B : A B = { x Z /( B ) x A} A B
5-36 Dilation of A by B : { A B = x Z /( Bˆ ) x A φ A B } B the structuring element
5-37 Opening of A by B : A B = ( A B) B A B
5-38 Closing of A by B : A B = ( A B) B A B
5-39 Dilation B = square x 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Erosion 5 5
5- Opening B = square x 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 Closing 5 5
5- Non Linear Filtering Erosion Erosion [7x7]
5- Non Linear Filtering Dilation
5-3 Non Linear Filtering Opening Erosion then Dilation Erosion [ 5 x 5 ] Dilation [ 5 x 5 ] Opening [ 5 x 5 ]
5- Non Linear Filtering Closing Dilation then Erosion Dilation [ 7 x 7 ] Erosion [ 7 x 7 ] closing [ 7 x 7 ]
5-5 borders Detection of Isolated points Detection on line Detection of contours (edges) «border» (edges) detection
5-6 Detection of Isolated points R = w i f i = w f + w f +... + w n f n (Image,Kernel) and test R > S Convolution Image 5 5 5 5 5 5 3 3 35 35 5 5 3 5 6 3 8 5 6
5-7 Line detection (horizontal) 9 (vertical) 5-5
5-8 5 5 5 (horizontal) 5 5 5 5 5 5 5 9 (vertical) 5 5 5 5 5 5 5 5
5-9 Edge detection First derivative Profil Seconde derivative
5-5 f = G + G x Gradients Operator f G x x f = = f G y y y Module(s) f = G x + G y G y Argument arg( f ) = tan G x Example (image) 58 5 7 3-8 +7-3 -
5-5 R = wi f i = f5 f9 R = wi f i = f 6 f8 Simplest operator f = f 5 f 8 + f 5 f 6 Roberts Operator f = f 5 f 9 + f 6 f 8
5-5 Prewitt Operator horizontal vertical R = w i f i = ( f 7 f ) + ( f 8 f ) + ( f 9 f 3 ) R = w i f i = ( f 3 f ) + ( f 6 f ) + ( f 9 f 7 )
5-53 Sobel Operator - - horizontal R = w i f i = ( f 7 f ) + ( f 8 f ) + ( f 9 f 3 ) vertical
5-5 - - - - - - - - - - - - -76-73 -7 - - - +3 +6 +3 9 9 3 9 9 3 86 9 5 5 5 5 3 3 3 3 Sobel operator - -33-69 -68-9
5-55 Laplacien Operator (seconde derivative) f f f = + x y f ( x, y ) = xy + sin( x ) 3 /x f = sin( x ) + 6 xy /y f = [ y 3 + cos( x ) 3 xy ] /x /y /x sin( x ) 3 y = Hf 3y 6 xy /y
5-56 Laplacien operator Noise sensitive Double ligne generation R = wi f i = f5 ( f + f + f 6 + f8 ) crossing
Liverpool RGB 5-57 Sobel 5 5 5 Liverpool 56 gris 5 5 5 5 5 5 5 Laplacien 5 5 5 5 5
5-58 Border detection Lines, contours, points Borders Local method Hough Transform
5-59 Border detection local Method f ( x, y ) f ( x ', y ' ) < S Module a ( x, y ) a ( x ', y ' ) < S Angle
5-6 Border detection Hough Transform Image Plane Parameters plane y = ax + b b = xa + y y b a x a and b fixed x and y fixed
5-6 b a
5-6 ALGORITHM case (u,v) => accumulator bmin amin b a) Choose a [a min a max ] b) Calculate b = xa + y c) Calculate cell (u,v) d) A(u,v)= A(u,v)+ amax bmax a ) For each cell (u,v), if A(u,v)>T, this cell represents a line
5-63 Problem b = xa + y y = ax + b y b a= a= x a= a= a= a= a x and y fixed Impossible for all a values
5-6 x cos(θ ) + y sin(θ ) = ρ y = ax + b ρmin y ρ θ x π/ π/ ρmax ρ Parameter space θ
5-65 x cos(θ ) + y sin(θ ) = ρ y ρ θ θ x ρ Image space Parameter space
5-66 5 5 5 3 35 5 5 5 3 5 5 5 5 3 35 5 5 5 3 5 5 3 35 5 5 5 3
5-67 Regions Finding Threshold Pixels merging Split and Merge
5-68 Formulation Image = Region R n R = Ri i = Ri is connexe Ri R j = φ for i j P ( Ri ) = True P ( Ri R j ) = False for i j
5-69 Threshold if g ( x, y ) = if f ( x, y) T f ( x, y ) > T with T = T [ ( x, y ), p( x, y ), f ] Image Pixel local property
5-7 Global Threshold T = T[ f ] Local Threshold T = T [ ( x, y ), p( x, y ), f ] T = T [ p( x, y ), f ]
5-7 5 Global Threshold 5 T = 6 5 3 35 5 5 55 5 3 5 6 7 5 5 5 T = 7 5 3 5 35 3 35 5 5 55 5 3 5 6 7 5 55 3 5 6 7 5 5 5 T = 8 3 35 5 5 55 3 5 6 7
5-7 6 5 Use the histogram 3 5 5 5 5 5 T = 5 5 3 35 5 5 5 5 55 3 5 6 7 5 3 35 5 5 55 3 5 6 7
5-73 Local Threshold T = T [ p( x, y ), f ( x, y )] T is the mean value of 5x5 window Centered on pixel (x,y) 5 5 5 5 5 5 3 3 35 35 5 5 5 5 55 55 3 5 6 7 3 5 6 7
5-7 Pixel growing Choice for a «seed» Growing if neighbooring Pixels veriy the property
5-75 Split and Merge Quadtree I Split : Split until the property is true In the sub-image Merge : Merge adjacent regions For which «grouping» verifyes the property
5-76 Property : Same gray level