Image Segmentation and Morphological Processing Digital Image Processing in Life- Science Aviad Baram
Image In Attributes out Image InImage out Processing vs Analysis Image processing: Image analysis: Enhance contrast SmoothRegionEdges “meaning”
Part I - Segmentation Subdivide the image into constituent regions or objects (sets) Based on properties of intensity values ▪Discontinuity – changes (e.g. edges) ▪Similarity – partition into similar regions
Basic set operations Union (R r ∪ R g ) Complementary (R rg c )Intersect (R r ∩R g ) Exclusive or (R r ⊕ R g )
Synonyms in set operations Selection ROI Make Inverse OR (Combine) AND XOR Mathematical Set (R i ) Complementary (R i c ) Union (R i ∪ R j ) Intersect (R i ∩R j ) Exclusive disjunction (R i ⊕ R j ) Binary Mask Inverse OR AND XOR
Automatic approaches ■ Discontinuity – Edge based methods ■ Classical gradient detectors (Sobel, Prewitt...) ■ Canny edge detector ■ Similarity - threshold Why? Human comprehension is far superior Unbiased High throughput – ImageJ macros
Edge detection Find the boundary of a region by identifying points, lines and edges Tools: ▪Second derivatives (Laplacian) operators ▪Very sensitive to noise ▪Double line detection (show example) ▪First derivative ▪Smoother ▪Less sensitive
Derivatives noise First derivative Second derivative
Derivatives noise First derivative Second derivative
Derivatives noise First derivative Second derivative
Laplacian double edge
Prewitt and Sobel DerivativeSobel
Laplacian of Gaussian - LoG Laplacian LoG
Canny edge detector angle norm Nonmaxima suppression along gradient Double threshold → use TH edge pixels as seeds to connect TL edges
Edge detection Summary 1 st derivative2 nd derivativeSource LoGSobelCanny
Similarity - Threshold Partition Image into regions ▪Global threshold ▪Adaptive threshold ▪Smaller image blocks ▪Threshold for each blocks ▪Interpolate results for each pixels
Global threshold - noise T1T1 T2T2 abc
Global threshold - background
Automatic global threshold Example 1 - mean: Initial estimate for T Segment into G 1 and G 2 Compute mean for G 1 and G 2 Compute new threshold G1G1 G2G2 G1G1 G2G2 Repeat until no significant change
Automatic global threshold Example 2 – Otsu: minimize error in pixel assignment to groups Global mean: m G Global variance: σ 2 G mean 1 mean 2 Between-class variance: σ 2 B “goodness” of TH: Calculate for all thresholds and choose the max σ 2 B smoothing images improves auto segmentation
Local thresholding Calculate T from “subimage” histogram (e.g. edges...) ⇒ apply to full image
Variable thresholding For each pixel, f(x,y), compute a threshold, T xy, based on m xy and σ xy of neighborhood S xy Mean m - meanσ - variance
Part II - Morphology Processing of region shapes
Structuring Elements
Erosion A⊖BA⊖B
Remove connecting lines Shrink regions
Dilation A⊕BA⊕B
Bridge gaps Grow regions Dilate ⇔ Erode C
Open A◦BA◦B Smooth contour Break narrow bridges Eliminate protrusions nX Erode → n X dilate
Close ABAB Smooth contour Fuse narrow breaks Eliminate small holes Fills gaps nX dilate → n X erode Open ⇔ Close C
Boundary extraction Subtract the eroded image from original
Skeletons Minimal set required for reconstruction ImageJ built in function – erode to single pixel
Fill holes Hole – background region surrounded by a foreground connected border
Hit or Miss A ⊛ B=(A ⊖ B 1 )∩(A C ⊖ B 2 ) Shape detection Probe for object Probe for background
Watershed ImageJ built inSegmentationGray level
ImageJ Set Measurement...
Gray level morphology ErodeDilateOpenClose
Examples Yael MutsafiAyelet Tetelboim