October 1, 2013Computer Vision Lecture 9: From Edges to Contours 1 Canny Edge Detector However, usually there will still be noise in the array E[i, j], i.e., non-zero values that do not correspond to any edge in the original image. In most cases, these values will be smaller than those indicating actual edges. We can then simply use a threshold T to eliminate the noise. All values of E[i, j] < T are set to 0, and the other values remain unchanged or are set to 1 (whatever you prefer). Then the Canny edge detector operation is complete.
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 2 Canny Edge Detector - Example Let us look at the following (already smoothed) sample image and perform Canny edge detection on it: grayscale image intensity values of same image
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 3 Canny Edge Detector - Example Applying the vertical and horizontal gradient filters gives us the following results: Q[i, j] P[i, j]
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 4 Canny Edge Detector - Example Based on P[i, j] and Q[i, j], we can now compute the magnitude and orientation of the gradient: M[i, j] [i, j] 0000 0000 0000 0000 0000 0000 0000 192 216 246 193 165 0000 191 203 208 213 183 0000 305 261 226 213 196 0000 212 218 226 228 345 0000 295 282 309 293 186
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 5 Canny Edge Detector - Example This allows us to compute the sector [i, j] for each angle [i, j]: [i, j] Remember the directions: 103 2[i,j]2 301
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 6 Canny Edge Detector - Example The last steps are nonmaxima suppression and thresholding (here we use T = 30): E[i, j] final result
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 7 Canny Edge Detector - Example Finally we visualize the detected edge pixels (0 = white, 1 = black) and indicate the precise edge locations (the pixels’ lower right corners) in the original image: edge locations in original image edge pixels
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 8 Evaluating Edge Detector Performance How can we decide which type of edge detector we should use in our application? For this purpose, we need to find a method for evaluating the performance of these detectors. First of all, we need to create one of more test images for which we know the actual locations and orientations of edges. A straightforward idea is to just draw an image showing geometric objects. One possible measure for edge detector performance is called the figure of merit.
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 9 Evaluating Edge Detector Performance The figure of merit FM is computed as follows: with number of detected edges I A, number of ideal edges I I, distance between the actual and ideal edges (as matched by an appropriate algorithm) d, and constant for penalizing displaced edges .
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 10 Evaluating Edge Detector Performance The maximum value of FM is 1, which indicates perfect performance. The closer FM is to 0, the poorer the performance. Of course even a poor edge detector can perform very well in artificial images that show, for example, only perfect rectangles. In order to perform a more meaningful analysis, we should add noise to our test images and see how well our edge detector can handle it. One possibility is to simulate varying degrees of Gaussian noise in our test images.
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 11 Simulating Gaussian Noise In order to simulate Gaussian noise, change the intensity of each pixel according to a Gaussian random distribution: probability intensity original intensity i of pixel Probability for new intensity i’ of pixel standard deviation of Gaussian determines amount of noise
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 12 Simulating Gaussian Noise To simulate a Gaussian random distribution, keep on choosing 2D random points in the marked rectangular area until one of them is under the Gaussian curve. Set i’ to the horizontal coordinate of that point. Set i’ to the horizontal coordinate of that point. probability intensity original intensity i of pixel new intensity i’
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 13 Evaluating Edge Detector Performance We can then measure the figure of merit as a function of the Gaussian noise added to the input image: of Gaussian noise figure of merit strong (robust) edge detector weak edge detector
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 14 From Edges to Contours In order to represent a region boundary, we have to link its local edges. Such a representation is called a contour. Closed contours indicate region boundaries. Open contours are usually parts of region boundaries with gaps due to noise or low contrast. We can represent a contour as an ordered list of edges or as a curve. A curve is a mathematical model of a contour.
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 15 Edge Relaxation The edge images generated by edge detection techniques (Sobel, Canny, etc.) are usually noisy. In these images, contours may be visible to the human eye, but they may contain gaps, and there are isolated edges that do not belong to an actual contour. We can use the edge relaxation technique to fill the gaps and remove the isolated edges. It is an iterative method that assigns confidence values to edges and updates these values.
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 16 Edge Relaxation Typically, this technique works on crack edges: pixelpixelpixel pixelpixelpixelebg i h a c d f
October 1, 2013Computer Vision Lecture 9: From Edges to Contours 17 Edge Relaxation Edges h and i can be used for non-maxima suppression similar to the Canny detector. We will not discuss this here. The edge pattern at an edge e can be described as a pair of integers: the number of connecting edges on the left (edges a, b, c) and the number of connecting edges on the right (d, f, g). Since the left and right sides are exchangeable, we simply write the smaller number first, e.g. 0-1, 1-3, 2-2. These edge patterns determine whether we should increase or decrease the current confidence value for e or leave it unchanged.