Lecture – 12
(Image Segmentation, Part - 2)
Image Gradient, Gradient Operators and Masks, Prewitt and Sobel Masks for
 Diagonal Edges, Laplacian, Laplacian of Gaussian(LoG), Marr-Hildreth edge
             detection algorithm, Zero crossing vs. Gradient
                                     By,
                         Dr. Ramesh Kumar Thakur
                             Assistant Professor
                         Center of AI, MANIT Bhopal
  M.Tech (NIT DGP), PhD (IIT Patna), Postdoc (Northwestern University, USA)
Image Gradient
Image Gradient
Gradient Operators and Masks
Prewitt and Sobel Masks for Diagonal Edges
Examples
Examples
Examples
Laplacian
Laplacian of Gaussian(LoG)
          Marr-Hildreth edge detection algorithm
• 1. Filter the input with an n by n Gaussian lowpass filter.
• 2. Compute the Laplacian of the image of step 1.
• 3. Find the zero crossing of the image from step 2.
• Approximate the zero crossing from LoG image to threshold the LoG image by setting all its positive values to white and
  all negative values to black.
• The zero crossing occur between positive and negative values of the thresholded LoG.
                      Zero crossing vs. Gradient
• Attractive
• – Zero crossing produces thinner edges
• – Noise reduction
• Drawbacks
• – Zero crossing creates closed loops. (spaghetti effect)
• – sophisticated computation.
• Gradient is more frequently used.
Zero crossing vs. Gradient
                                                      Numerical
                         1     2        5
1. Consider an image     5     5        5 . Show the output of any edge detection algorithm?
                         5     3        2
• Ans:- Let us consider the application of the Sobel’s edge detection filters. The edge detection filters are as below:
         -1   -2   -1              -1       0   1
• gx =   0    0    0    gy =       -2       0   2
         1    2    1               -1       0   1
• Applying gx filter, we get gx = -1-4-5+5+6+2 = 3
• Applying gy filter, we get gy = -1-10-5+5+10+2 = 1
• The gradient, denoted by ∆f = grad(f) = (3 1)T
• Magnitude (length of vector) = mag(∆f) = (gx2 + gy2)1/2 = sqrt (9 + 1) = 3.16
• Direction of the edge = tan-1(gy/gx) = tan-1(1/3) = 18.26 degrees
• Thus, we see that the edge is located at an angle of 18.26 degrees wrt x-axis