Lecture 7, grayscale Morphological image processing II Grayscale morphology and distance transforms

GW 9 Ida-Maria Suggested problem: Suggest how to combine dilation, and logical operations to reduce/solve a problem with varying background. GW fig 9.27

dilation erosion choose max value of f+b choose min value of f-b effect: effect: • b with positive elements ‰ (often) brighter output • b with positive elements ‰ (often) darker output • dark details are reduced or eliminated • bright details are reduced

geometrical interpretation effects 1D • – remove small bright details – remove dark details – leave overall grey-levels – leave bright features – leave larger bright features

opening

closing fig 9.30 properties

BINARY GREY-LEVEL • duality with respect to • duality with respect to complementation and complementation and reflection: reflection: ( )C ( C ˆ) ( • )c = c ˆ A• B = A A B f b f Ab

• opening • opening

¢

–A B subset/image of A ¡

erosion closing ⊆ ⊆ – f b f ¢

–C D ‰ C B D B ¢ ¡ ¡

– if f1 f2, then (f1 b) (f2 b)

– (A B) B= A B

¡ ¡ ¡ • closing – (f b) b=f b – A subset/image of A •B • closing –C⊆D ‰ C•B ⊆ D•B – f ¢ (f ‡b)

original • • • £ – (A B) B= A B – if f1 £ f2, then (f1 ‡b) (f2 ‡b)

– (f ‡b) ‡b=f ‡b ¤

e ¤ r: ¤ ¤ domain of e is subset of domain of r and e(x,y)≤r(x,y) for all (x,y) in domain of e.

dilation opening

application: smoothing application: gradient image

⊕ can be achieved by opening followed by closing g=(f b)-(f ¥ b) ‰ removal or attenuation of bright & dark artifacts/noise subtract eroded image from dilated

•similar to boundary extraction for binary case (morphology) •compare with edge detectors, ... •Rather direction independent

Distance transforms Different metrics (fill in!) Euclidean DE(p,q)=

Input: binary image City block D (p,q)= Output: in each object (background) pixel, write the distance to 4 the closest background (object) pixel. Chessboard D (p,q)= Def. A D is a metric (distance measure) for 8 the pixels p, q and z if Weighted measures: a) D(p,q)>=0 (D(p,q)=0 if p=q) Chamfer(3-4) b) D(p,q)=D(q,p) c) D(p,z)<=D(p,q)+D(q,z) Chamfer(5-7-11) Algorithm for distance transformation (distance from each object pixel to the closest background pixel) p=current pixel g1-g4= neighboring pixels w1-w4= weights (according to choice of metric)

1. Set background pixels=0 and objekt pixels= infinity (or max (e.g. 255)) 2. Forward pass, from (0,0) to (max(x),max(y)): Mask: w1 w2 w3 w4 p

if p>0, p=min(g i+w i), i=1,2,3,4 3. Backward pass, from (max(x),max(y)) to (0,0):

Mask: p w 4 w1 w2 w3

if p>0, p=min(p, min(g i+w i)) i=1,2,3,4

Applications using the distance transform (DT) iii) Dirichlet tesselation (Voroni diagram) Given a number of seeds p 1, p 2, ...p m, associate with each seed p i all regions closer to p i than any other seed. 1. Generate the DT with the seeds as background. i) Find the shortest path between two point a and b 2. The connected maxima of the DT is the Voronidiagram, and the 1. generate the DT with a as the object region associated with a point is the Dirichlet tesselation for the point. 2. go from b in the steepest gradient direction

ii) Find the radius of a round object 1. generate the DT of the object 2. max value = radius

* Segmentation using watershed!

iv. Skeletons Skeletons (Centers of Maximal Discs) A disc is made up of all pixels that are within a given radius r. The skeleton of a binary object is the union of Definitions: all disc centers needed to reconstruct the object using O=object the corresponding discs. B=background S=skeleton O B Algorithm: Find the skeleton, Centers of Maximal Discs (CMD) * reversibel Then S •S topological equivalent O •S centered in O 1. generate DT of object •S one pixel wide (difficult) 2. Identify CMDs (smalest set of maxima) •O can be reconstructed 3. Link CMDs from S "Pruning"= remove small branches (no longer fully reversible) Skeleton

Skeletonisation based on thinning (not reversible)

Skeleton using Chamfer(3,4) DT, Skeleton using Chamfer(3,4) DT, followed by pruning (not fully no pruning (fully reversible) reversible)