Slide 1

Slide 1 text

Digital Image Processing Segmentation (Week 10-13) NHSM - 4th year - Fall 2024 - Prof. Mohammed Hachama [email protected] http://hachama.github.io/home/

Slide 2

Slide 2 text

Outline Introduction Edge Detection Simple Detectors Segmentation: Regions NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 2/25

Slide 3

Slide 3 text

Introduction NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 3/25

Slide 4

Slide 4 text

What is segmentation? • Partitioning an image into a minimal number of connected regions Ri (in a specified sense) • Each region must satisfy a property P(Ri ) Contour/Region Duality NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 4/25

Slide 5

Slide 5 text

What is segmentation? Contour/Region Duality NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 4/25

Slide 6

Slide 6 text

Contours NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 5/25

Slide 7

Slide 7 text

What is an edge? • It is a boundary that separates two objects in an image. • A discontinuity in the image. • A sharp and strong change in intensity. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 8

Slide 8 text

What is an edge? • An edge is a sharp and strong change in intensity. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 9

Slide 9 text

What is an edge? • Origins of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 10

Slide 10 text

What is an edge? • Origins of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 11

Slide 11 text

What is an edge? • Origins of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 12

Slide 12 text

What is an edge? • Origins of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 13

Slide 13 text

What is an edge? • Types of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 14

Slide 14 text

What is an edge? • Types of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 15

Slide 15 text

What is an edge? • Types of edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 6/25

Slide 16

Slide 16 text

Outline Introduction Edge Detection Simple Detectors Segmentation: Regions NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 7/25

Slide 17

Slide 17 text

Simple detectors • Detection of points: Apply the following mask and threshold the resulting image    −1 −1 −1 −1 8 −1 −1 −1 −1    NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 8/25

Slide 18

Slide 18 text

Simple detectors • Line detection: Filters defining 4 directions E-W, NW-SE, N-S, NE-SW    −1 −1 −1 2 2 2 −1 −1 −1       2 −1 −1 −1 2 −1 −1 −1 2       −1 2 −1 −1 2 −1 −1 2 −1       −1 −1 2 −1 2 −1 2 −1 −1    NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 8/25

Slide 19

Slide 19 text

Simple detectors • Line detection: Example NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 8/25

Slide 20

Slide 20 text

Simple detectors • Line detection: Examples NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 8/25

Slide 21

Slide 21 text

Derivative methods: Gradient • Derivative of an image and edges NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 22

Slide 22 text

Derivative methods: Gradient • Derivative of an image and edges • Norm: G = G2 x + G2 y ∼ Gx + Gy • Direction: θ = arctan(Gy /Gx ) NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 23

Slide 23 text

Derivative methods: Gradient • Example of edge detection NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 24

Slide 24 text

Derivative methods: Gradient • Simple approximations of the discrete derivative −1 1 −1 1 −1 0 1 −1 0 1 • Roberts filters: directional derivatives 1 0 0 −1 0 1 −1 0 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 25

Slide 25 text

Derivative methods: Gradient • Prewitt filters: image smoothing + image derivative −1 −1 −1 0 0 0 1 1 1 −1 0 1 −1 0 1 −1 0 1 • Averaging + Derivation    −1 0 1 −1 0 1 −1 0 1    =    1 1 1    ∗ (−1 0 1) Edge detection less sensitive to noise. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 26

Slide 26 text

Derivative methods: Gradient • Sobel filters −1 −2 −1 0 0 0 1 2 1 −1 0 1 −2 0 2 −1 0 1 • Gaussian + Derivation    −1 0 1 −2 0 1 −1 0 1    =    1 2 1    ∗ (−1 0 1) Edge detection less sensitive to noise NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 27

Slide 27 text

Derivative methods: Gradient • Example of edge detection NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 9/25

Slide 28

Slide 28 text

Contour detection examples • Contours Detection • Robert gradient, |I|= I2 x + I2 y and a threshold T = 5. I = 9 9 9 9 9 9 9 2 2 9 8 9 9 9 9 2 2 2 9 9 9 9 9 9 3 2 2 9 9 9 9 9 2 2 2 2 7 9 9 9 9 2 2 2 2 9 9 9 9 2 2 2 2 2 9 9 9 9 2 2 2 4 2 9 9 9 2 2 2 2 2 2 9 9 2 2 2 2 1 2 2 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 29

Slide 29 text

Contour detection examples • Contours Detection • Robert gradient, |I|= I2 x + I2 y and a threshold T = 5. Rx = 1 0 0 −1 , Ix = 1 0 0 0 0 7 7 0 0 −1 0 0 0 6 0 0 0 0 0 0 7 7 1 0 0 0 0 0 7 0 0 0 −2 0 0 7 7 0 0 0 0 0 0 7 0 0 −2 0 0 0 7 7 0 0 0 2 0 7 7 0 0 1 0 0 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 30

Slide 30 text

Contour detection examples • Contours Detection • Robert gradient, |I|= I2 x + I2 y and a threshold T = 5. Ry = 0 1 −1 0 , Iy = 0 1 0 0 0 0 0 0 −1 0 0 0 0 −7 −1 0 0 0 0 0 0 1 0 0 2 0 0 0 −7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 −7 0 0 0 −2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 31

Slide 31 text

Contour detection examples • Contours Detection • Robert gradient, |I|= I2 x + I2 y and a threshold T = 5. |I|= 1 1 0 0 0 7 7 0 1 1 0 0 0 9.2 1 0 0 0 0 0 7 7.1 1 0 2 0 0 0 9.9 0 0 0 2 0 0 7 7 0 0 0 0 0 0 9.9 0 0 2 2 0 0 7 7 0 0 2 2 0 7 7 0 0 1 1 0 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 32

Slide 32 text

Contour detection examples • Contours Detection • Robert gradient, |I|= I2 x + I2 y and a threshold T = 5. Edge = 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 33

Slide 33 text

Contour detection examples • Edge detection with the Sobel filter Ix NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 34

Slide 34 text

Contour detection examples • Edge detection with the Sobel filter Iy NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 35

Slide 35 text

Contour detection examples • Edge detection with the Sobel filter Gradient norm NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 36

Slide 36 text

Contour detection examples • Edge detection with the Sobel filter Edges: NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 10/25

Slide 37

Slide 37 text

Derivative methods: Laplacian • Contours Detection NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 11/25

Slide 38

Slide 38 text

Derivative methods: Laplacian • Several discrete approximations of the Laplacian exist.    0 1 0 1 −4 1 0 1 0       1 1 1 1 −8 1 1 1 1       1 4 1 4 −20 4 1 4 1    • Isotropic: Symmetric w.r.t. rotations. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 11/25

Slide 39

Slide 39 text

Derivative methods: Laplacian • The Laplacian, like all edge detectors, is very sensitive to noise. • Smoothing (Gaussian) the image before detecting edges. • Edges = zero-crossings of the Laplacian of Gaussian LoG ∗ I = ∆ ∗ G ∗ I = ∆G ∗ I LoG(x, y) = − 1 πσ4 1 − x2 + y2 2σ2 e− x2+y2 2σ2 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 11/25

Slide 40

Slide 40 text

Derivative methods: Laplacian • Laplacian Filter NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 11/25

Slide 41

Slide 41 text

Derivative methods: Laplacian • Edges = zero-crossings of the Laplacian NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 11/25

Slide 42

Slide 42 text

Canny method • 1. Apply a Gaussian filter to the image • Low-pass filter to remove noise • 2. Calculate the gradient intensity in the image • Sobel filter in X and Y directions • Calculate the magnitude |G|= |Gx |+|Gy | • 3. Calculate the gradient directions in the image • Gradient direction θ = arctan(Gy /Gx ) • Round the directions to the nearest multiple of 45 degrees NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 12/25

Slide 43

Slide 43 text

Canny method • 4. Non-maximum suppression • If the gradient magnitude at a pixel is less than the gradient magnitudes of its two neighbors along the gradient direction, then set the magnitude of that pixel to zero. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 12/25

Slide 44

Slide 44 text

Canny method • 5. Edge thresholding (hysteresis) • Uses two thresholds: a high threshold (Sh) and a low threshold (Sb) • For each pixel • If ∥∇I(x, y)∥< Sb, then the pixel is set to zero (non-edge). • If ∥∇I(x, y)∥> Sh, then the pixel is an edge. • If Sb ≤ ∥∇I(x, y)∥≤ Sh, then the pixel is an edge if it is connected to another pixel already accepted as an edge. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 12/25

Slide 45

Slide 45 text

Canny method • Example NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 12/25

Slide 46

Slide 46 text

Edge Detection Chain • No operator is perfect for detecting edges • In practice, we obtain incomplete edges • There are superfluous pixels • There are gaps • There are errors in edge pixel positioning and orientation • An edge detection operator is just the first step in the segmentation chain NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 13/25

Slide 47

Slide 47 text

Edge Detection Chain • There are global approaches for edge detection • We do not only look for edge pixels • We seek the complete edge • We look for multiple pixels corresponding to an edge • How to define the edge? Problem? • Different techniques • Here: Hough Transform NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 13/25

Slide 48

Slide 48 text

Hough method • Global approach: lines representation • Plan x − y : yi = axi + b • An infinite number of lines pass through (xi , yi ) and only one line for (a, b). • Parametric plan a − b: b = −xi a + yi • Only one line for (xi , yi ) and an infinite nuber of lines pass through (a, b) NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 49

Slide 49 text

Hough method • 1. Edge Detection (Gradient, Laplacian, ...) • 2. For each (xi , yi ) in the x-y plane (detected by the edge detector), ”draw” a line in the a-b parameter plane • 3. The intersections (cells) of lines in the a-b plane indicate the actual lines present in the x-y plane NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 50

Slide 50 text

Hough method • Problem: The slope approaches infinity for lines that are close to vertical! • Solution: Represent using polar coordinates ρ = x cos θ + y sin θ NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 51

Slide 51 text

Hough method • Application NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 52

Slide 52 text

Hough method • Application NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 53

Slide 53 text

Hough method • Application NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 54

Slide 54 text

Hough method • Application NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 14/25

Slide 55

Slide 55 text

Application: document scanner Building a document scanner: • Step 1: Detect edges. • Step 2: Use the edges in the image to find the contour (outline) representing the piece of paper being scanned. • Step 3: Apply a perspective transform to obtain the top-down view of the document. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 15/25

Slide 56

Slide 56 text

Segmentation NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 16/25

Slide 57

Slide 57 text

Thresholding • Thresholding is a simple and very popular method for digital image processing • It is a classification method, not a region segmentation method • Pixel-based approach (not region or contour) • Thresholding can be • Global: a single threshold for the entire image • Local: a threshold for a portion of the image • Adaptive: a threshold that adjusts according to different parts of the image NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 17/25

Slide 58

Slide 58 text

Global Thresholding Basic Principle • Basic thresholding (2 classes): • If value(pixel) ≥ threshold then value(pixel) = 1 • If value(pixel) < threshold then value(pixel) = 0 • The result of thresholding is a binary image • 0 or 1 (sometimes transformed to 0:255 for display) • Problem: Choosing the threshold! NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 59

Slide 59 text

Global Thresholding • Threshold Selection: Histogram Thresholding NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 60

Slide 60 text

Global Thresholding • Threshold Selection: Simple Histogram Thresholding NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 61

Slide 61 text

Global Thresholding • Threshold Selection: Histogram Thresholding • Advantages • Universal, real-time, simplicity • Works well on multi-modal histograms • Disadvantages • Requires knowledge of the number of classes. • Appearance of false elements (no spatial component considered). • Number of modes often equals the expected number of classes. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 62

Slide 62 text

Global Thresholding • Threshold Selection: Histogram Thresholding • How to find the right threshold (T)? • A value obtained through testing • The average value of gray levels • The median value between the maximum and minimum gray levels • A value that balances the two sections of the histogram • There are automatic algorithms to find the threshold: Averaging, Otsu, Kittler, ... NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 63

Slide 63 text

Global Thresholding • Averaging Method 1. Choose an initial threshold S = S0 . 2. Divide the pixels into two classes using S. 3. Update the threshold S as the average of the two mean gray levels of the two classes S′ = m1+m2 2 . 4. If |S − S′|< δ, stop. S = S′. Otherwise, set S = S′ and return to step 2. Initial image (S0 = 76), Segm./S1 = 174.66+17.7 2 = 96.18, Final segmentation NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 64

Slide 64 text

Global Thresholding • Otsu’s Method NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 65

Slide 65 text

Global Thresholding • Otsu’s Method NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 18/25

Slide 66

Slide 66 text

Local or Adaptive Thresholding • Global thresholding: Problems NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 19/25

Slide 67

Slide 67 text

Local or Adaptive Thresholding • Global thresholding: Problems NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 19/25

Slide 68

Slide 68 text

Local or Adaptive Thresholding • Divide the image into sub-images • Threshold each sub-image independently • The 4 corner sub-images are not processed because variance < 100 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 19/25

Slide 69

Slide 69 text

Local or Adaptive Thresholding • Example NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 19/25

Slide 70

Slide 70 text

Region growing • ”Grow a region starting with a small initial region (for example, a single pixel).” • ”Criterion for adding a pixel to a region:” • ”The difference between the intensity of the new pixel and the average intensity of the pixels in the region does not exceed a predefined threshold δ.” NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 71

Slide 71 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 72

Slide 72 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 73

Slide 73 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 74

Slide 74 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 75

Slide 75 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 76

Slide 76 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 77

Slide 77 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 78

Slide 78 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 79

Slide 79 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 80

Slide 80 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 81

Slide 81 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 82

Slide 82 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 83

Slide 83 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 84

Slide 84 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 85

Slide 85 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 86

Slide 86 text

Region growing • Exemple 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 87

Slide 87 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 88

Slide 88 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 89

Slide 89 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 90

Slide 90 text

Region growing • Example 1 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 91

Slide 91 text

Region growing • Example 2 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 92

Slide 92 text

Region growing • Example 2 NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 20/25

Slide 93

Slide 93 text

Split-and-Merge • Splitting Step: Recursively divide any non-homogeneous block based on a defined criterion, such as variance, max-min difference, etc. • Dividing a block results in 4 sub-blocks. • Attributes of each sub-block are recalculated. • Merging Step: Combine adjacent blocks representing homogeneous regions based on a defined criterion. • Example: Homogeneity criterion — A region is homogeneous if all its pixels have the same intensity. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 94

Slide 94 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 95

Slide 95 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 96

Slide 96 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 97

Slide 97 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 98

Slide 98 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 99

Slide 99 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 100

Slide 100 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 101

Slide 101 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 102

Slide 102 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 103

Slide 103 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 104

Slide 104 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 105

Slide 105 text

Split-and-Merge • Example: Split step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 106

Slide 106 text

Split-and-Merge • Example: merging step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 107

Slide 107 text

Split-and-Merge • Example: merging step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 108

Slide 108 text

Split-and-Merge • Example: merging step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 109

Slide 109 text

Split-and-Merge • Example: merging step NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 110

Slide 110 text

Split-and-Merge • Examples : Different thresholds NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 111

Slide 111 text

Split-and-Merge • Examples: Different thresholds NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 21/25

Slide 112

Slide 112 text

Ligne de partage des eaux (Watershed) NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 22/25

Slide 113

Slide 113 text

Connected Component Labeling • Assign a unique number (label) to each region. • Perform two passes over the image. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 114

Slide 114 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 115

Slide 115 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 116

Slide 116 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 117

Slide 117 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 118

Slide 118 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 119

Slide 119 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 120

Slide 120 text

Connected Component Labeling • First pass: from left to right and top to bottom. • Assign to each pixel in a region the smallest label among its top and left neighbors, or a new label. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 121

Slide 121 text

Connected Component Labeling • Second pass: from right to left and bottom to top. • Assign to each pixel in a region the smallest label among its own and its bottom and right neighbors’ labels. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 122

Slide 122 text

Connected Component Labeling • Second pass: from right to left and bottom to top. • Assign to each pixel in a region the smallest label among its own and its bottom and right neighbors’ labels. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 123

Slide 123 text

Connected Component Labeling • Second pass: from right to left and bottom to top. • Assign to each pixel in a region the smallest label among its own and its bottom and right neighbors’ labels. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 124

Slide 124 text

Connected Component Labeling • With two passes, we have completed the labeling of regions. Sometimes more than two passes are needed. For example: spiral regions! • Continue the passes, in one direction then the other, until no more label changes occur. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 23/25

Slide 125

Slide 125 text

Classification • Classification = assigning a set of objects (pixels) into different groups (classes) based on their characteristics or features (Gray level, color, gradient, local statistics, ...) • Types of classification • Supervised: The characteristics of the classes are known a priori. Examples: Minimum distance, k-nearest neighbors, statistical models (probability distributions of models), ... • Unsupervised (clustering): Classification is done based on the data and from the data directly. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 126

Slide 126 text

Classification • The k-Nearest Neighbors Classifier • Classes are defined by a few reference elements. • For a new object (pixel), the k closest reference objects are determined. • Each new object is assigned to the class of the majority of its neighbors. • The Minimum-Distance-to-Mean Classifier • Classes are defined by their centers. • Each new object is assigned to the class of the nearest center. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 127

Slide 127 text

Classification: K-means • We want to divide the points into k groups (clusters). • k is given in advance (a parameter of the algorithm). • The center of a group is defined as the average of the elements (pixels) in the group. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 128

Slide 128 text

Classification: K-means • 1. Partition the data into k non-empty subsets. • 2. Calculate the centers of the current groups. • 3. Data points are assigned to the group whose center is closest. • 4. Return to step 2. • Stop when the groups are approximately constant. NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 129

Slide 129 text

Classification NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 130

Slide 130 text

Classification NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 24/25

Slide 131

Slide 131 text

Conclusion NHSM - 4th year: Digital Image Processing - Segmentation (Week 10-13) - M. Hachama ([email protected]) 25/25