binary image operations
play

Binary image operations pine spruce friday & monday GW 2.5, - PDF document

Binary image operations pine spruce friday & monday GW 2.5, 11.1.1, 11.1.5, 11.2.2, 11.4 different objects different shape different texture stina@cb.uu.se recognition and interpretation using computerized image analysis Friday 22/3


  1. Binary image operations pine spruce friday & monday GW 2.5, 11.1.1, 11.1.5, 11.2.2, 11.4 different objects different shape different texture stina@cb.uu.se recognition and interpretation using computerized image analysis Friday 22/3 partitioning of 2D space • connectedness – neighbourhood relations – connected components • identification of connected components – labelling • measuring distances in an image square rectangular hexagonal – distance transforms (non-square) 1

  2. neighbours neighbourhood pixel p with coordinates (x,y) 6-neighbours 4-neighbours 8-neighbours N 4 (p): (hexagonal) (square) N 8 (p): 4-neighbourhood • neighbourhood 8-neighbourhood • neighbours of a pixel ( , − 1 ) ( − 1 , − 1 ) ( , − 1 ) ( + 1 , − 1 ) x y x y x y x y ( 1 , ) ( 1 , ) x − y x + y ( x − 1 , ) y ( x + 1 , ) y – horizontal/vertical, edge, kant ( , + 1 ) ( − 1 , + 1 ) ( , + 1 ) ( + 1 , + 1 ) x y x y x y x y – diagonal, point, punkt, hörn, vertex adjacency similarity object O – all pixels with a certain ”similarity” • 4-adjacent • m-adjacent (mix) V – set of grey-levels – p & q belongs to O – q is in N 4 (p) example: and q is in N 4 (p) – q is a point neighbour grey-level in V={20,21,…,30} AND p and q have no • 8-adjacent edge neighbours in – p & q belongs to O O common and q are in N 8 (p) O binary ( bi-level! ) images: only 0s and 1s object/region (1) and background (0) 2

  3. path path between two pixels p=(x,y) and q=(s,t) (x,y)=(x 0 ,y 0 ) adjacent (x 1 ,y 1 ) ... (x n-1 ,y n-1 ) adjacent 8-path 4-path (x n ,y n )=(s,t) p and q are connected if there is a path between p and q connected component connected component labelling • a pixel p belongs to the object O • every connected component is given an • connected component in O containing p: identity • represented by a grey-level image – all pixels that are connected with p – label image • every two pixels in a connected component are connected – grey-level for each pixel = identity • connected components are 4- or 8- connected if O consists of only one connected component � connected set 3

  4. labelling using FloodFill example of FloodFill • initially all pixel in the label image = 0 • given the binary image – find a pixel in the first connected component – fill the first connected component with label 1 – look for the next connected component pixel in the binary image having 0 in the label image – fill the next connected component – ... labelling using a two scan example of algorithm two scan algorithm • initially • change all labels in the equivalence table – object pixels = 255 to the smallest – background pixels = 0 • if object pixel A<255 – if object pixel B or C<255 • A=min(B,C) – otherwise • A=new label • equivalence table updated 4-connectedness 8-connectedness scan 2 scan 1 4

  5. label image in IMP connectivity – object and background • connected components of the object (O i ) • the object O is the union of all O i • the complement of O (O C ) consists of – background • subset of O C connected to the border of the image – holes • remaining part of O C using connected component connectivity paradox labelling • removal of connected components touching the a closed curve divides the plane into two (distinct) connected components image border – label – two scans 1. store label for object pixel at image border 2. if pixel=stored value � set to 0 • fill holes in the object – label the inverse image – remove connected components touching the image border – holes + original image how many background components?!? 5

  6. using connected component filling holes labelling • count number of connected components • extract information for a specific connected component original image inverse image original image holes – size – compactness – ... labelled remove connected output inverse image components at image border distances boundary, border, contour, edge, ... consider an object O (connected set) boundary = the set of pixels with one or more neighbours not in O length, straightness, ... NOTE! connectivity used for object/background in case 8-connected object: thickness boundary = pixels with 4-neighbour in background 6

  7. measuring distances in an distance image Z 2 • distance functions: x=(x 1 ,x 2 ),y=(y 1 ,y 2 ) ∈ Z – d E (x,y)= || x-y || 2 = � {(x 1 -y 1 ) 2 +(x 2 -y 2 ) 2 } l 2 – d city (x,y)= || x-y || 1 = | x 1 -y 1 | + | x 2 -y 2 | l 1 – d chess (x,y)= || x-y || � =max( | x 1 -y 1 | , | x 2 -y 2 | ) l � • intuitively: Euclidean distance • often represented by a distance transform – each object pixel is labelled with distance to 7 2 3 2 + Euclidean closest voxel in background 7 3 + city block, number of steps is 4-path 3 4 + chessboard, number of steps in 8-path metric – desired property local vs. global l 1 DEFINITION. A function d:Z 2 � Z 2 is a metric if and only if for any points (=pixels) x,y,z ∈ Z 2 the following holds: l 2 l � • d(x,y) � 0 and d(x,y)=0 only when x=y positive definite • d(x,y)=d(y,x) symmetric A known distance from A • d(x,z) � d(x,y)+d(x,z) fulfils � -inequality unknown distance from A 7

  8. simple distance distance transform (DT) • number of steps in a minimal path • representation of distances in an image • city block: 4-connectedness • grey-level image – d city (x,y)= || x-y || 1 = | x 1 -y 1 | + | x 2 -y 2 | l 1 – replica of binary image – each object pixel is labelled with the distance • chessboard: 8-connectedness to its closest pixel in the background – d chess (x,y)= || x-y || � =max( | x 1 -y 1 | , | x 2 -y 2 | ) l � • from binary image to DT by a distance • mix � octagonal distance transformation • DT gives important information introduced by Rosenfeld and Pfaltz in 1966 & 1968 examples of distance DTs with numbers transforms 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 1 1 2 0 0 0 0 0 0 1 2 3 4 0 0 0 0 0 0 1 1 2 2 0 0 0 0 0 1 2 3 4 5 0 0 0 0 0 1 1 2 2 3 0 0 0 0 1 2 3 4 5 6 0 0 0 0 1 1 2 2 3 3 0 0 0 1 2 3 4 5 6 7 0 0 0 1 1 2 2 3 3 4 0 0 1 2 3 4 5 6 7 8 0 0 1 1 2 2 3 3 4 4 0 1 2 3 4 5 6 7 8 9 0 1 1 2 2 3 3 4 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 2 3 3 4 4 5 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 3 4 4 5 5 6 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 4 5 5 6 6 city block chess board city block chess board 8

  9. computing DT city block forward backward • initially: object = � , background = 0 • one forward and one backward scan • current distance label of a pixel is compared to the distance labels for its already visited neighbours • update if shorter distance p p city block chess board chess board comparison: discs forward backward a disc is defined by centre pixel (p 0 ) and radius (r): all pixels closer than r to p 0 { } ( ) = ∈ n ; , ≤ B p Z d p p r 0 city block chess board Euclidean 9

  10. simple distance transforms weighted distance transforms chamfering • use length of shortest path • assign weights to steps in path corresponding to neighbourhood relation – a for steps in edge directions city-block chess board octagonal – b for steps in point directions dist=11 dist=7 (diagonal only b a b a , b every even) a p a dist=8 b a b more or less: by Rutovitz & Hilditch 1969 city block 1 , 2 distance=number of steps 1 , 1 later Borgefors 1984/86 chess board 3 , 4 algorithm for weighted DTs for y=1 to n forward backward +b +a +b for x=1 to n ( ) ( ) ( ) ( ) I x y , = min I x + i y , + j + w i j , +a ( ) i j , ∈ fwd for y=n downto 1 for x=n downto 1 ( ) ( ) ( ) ( ) +0 +a , = min + , + + , I x y I x i y j w i j ( ) i j , ∈ bwd +b +a +b ( ) { } w i j i j , , , ∈ − 1 0 1 , , weights ( ) i , j pixel used in forward ( fwd ) and backward ( bwd ) scan ( ) I , i j image of size n x n 10

  11. using a larger neighbourhood DTs in IMP even better approximation using knight step (c) original 2 2 2 b c a c b c b a b a 2 2 5 , 7 , 11 a a p a a region of interst c b a b c gives maximum difference 2 2 2 a c a c b with Euclidean distance of 2% DT (<3,4>) discs maximal difference – Euclidean 3 , 4 5 , 7 , 11 a b diff a b c diff 1 1.4142 9.0% 1 1.414 2.236 2.8% 3 , 4 5 , 7 , 11 1 2 58.6% 2 1 city block Euclidean 5 7 11 2.0% 1 1 41.4% a opt b opt c opt 1.4% a opt b opt 4.5% 2 3 13.4% 3 4 8.1% 8 11 7.3% 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend