Edge detection Edge Detection in Images • Finding the contour of objects in a scene Edge Detection in Images • What is an object? It is one of the goals of computer vision to identify objects in scenes. Edge Detection in Images • Edges have different sources. What is an Edge • Lets define an edge to be a discontinuity in image intensity function. • Edge Models – – – – Step Edge Ramp Edge Roof Edge Spike Edge Detecting Discontinuities • Discontinuities in signal can be detected by computing the derivative of the signal. Differentiation and convolution • Recall f f x f x lim 0 x • Now this is linear and shift invariant, so must be the result of a convolution. • We could approximate this as f xn 1 f x f x x (which is obviously a convolution with Kernel 1 ; 1it’s not a very good way to do things, as we shall see) Finite Difference in 2D f x, y f x , y f x, y lim 0 x f x, y f x, y f x, y lim 0 y Definition f x, y f xn 1 , ym f xn , ym x x f x, y f xn , ym1 f xn , ym y x Discrete Approximation 1 1 1 1 Convolution Kernels Finite differences I x I * 1 1 I 1 Iy I * 1 Frequency Response of Differential Kernel f x f x x Fourier Transform Fourier Transform F f u uF f u Noise • Simplest noise model – independent stationary additive Gaussian noise – the noise value at each pixel is given by an independent draw from the same normal probability distribution • Issues – – – – this model allows noise values that could be greater than maximum camera output or less than zero for small standard deviations, this isn’t too much of a problem - it’s a fairly good model independence may not be justified (e.g. damage to lens) may not be stationary (e.g. thermal gradients in the ccd) Finite differences and noise • Finite difference filters respond strongly to noise – • • What is to be done? – obvious reason: image noise results in pixels that look very different from their neighbours – Generally, the larger the noise the stronger the response – intuitively, most pixels in images look quite a lot like their neighbours this is true even at an edge; along the edge they’re similar, across the edge they’re not suggests that smoothing the image should help, by forcing pixels different to their neighbours (=noise pixels?) to look more like neighbours Finite differences responding to noise Increasing noise -> (this is zero mean additive gaussian noise) Smoothing reduces noise • Generally expect pixels to “be like” their neighbours – surfaces turn slowly – relatively few reflectance changes • Generally expect noise processes to be independent from pixel to pixel • • Implies that smoothing suppresses noise, for appropriate noise models Scale – – – – the parameter in the symmetric Gaussian as this parameter goes up, more pixels are involved in the average and the image gets more blurred and noise is more effectively suppressed The effects of smoothing Each row shows smoothing with gaussians of different width; each column shows different realisations of an image of gaussian noise. Classical Operators Prewitt’s Operator 1 1 1 1 1 1 Smooth 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 1 Differentiate 1 1 1 1 1 0 0 0 1 1 1 Classical Operators Sobel’s Operator 1 1 2 2 1 1 Smooth 1 1 1 0 1 2 0 2 1 0 1 Differentiate 1 2 1 1 2 1 1 1 2 1 1 0 0 0 1 2 1 Gaussian Filter x2 y 2 G x, y exp 2 2 2 2 1 i k 12 j k 12 H i, j exp 2 2 2 2 1 where H i, j is 2k 1 2k 1 array Detecting Edges in Image • Sobel Edge Detector * 1 0 1 2 0 2 1 0 1 d I dx Image I * 2 1 1 0 0 0 1 2 1 d I dy d d I I dx dy 2 2 Edges Threshold any alternative ? Quality of an Edge Detector • Robustness to Noise • Localization • Too Many/Too less Responses Poor robustness to noise Poor localization True Edge Too many responses Canny Edge Detector • Criterion 1: Good Detection: The optimal detector must minimize the probability of false positives as well as false negatives. • Criterion 2: Good Localization: The edges detected must be as close as possible to the true edges. • Single Response Constraint: The detector must return one point only for each edge point. Canny Edge Detector • Difficult to find closed-form solutions. Canny Edge Detector • Convolution with derivative of Gaussian • Non-maximum Suppression • Hysteresis Thresholding Canny Edge Detector • Smooth by Gaussian 1 G e 2 S G * I • Compute x and y derivatives S S x T S Sx y Sy T • Compute gradient magnitude and orientation S S x2 S y2 tan 1 Sy Sx x2 y 2 2 2 Canny Edge Operator S G * I G * I G G x G S *I x G y T G *I y T Canny Edge Detector Sx I Sy Canny Edge Detector S S x2 S y2 I S Threshold 25 Non-Maximum Suppression We wish to mark points along the curve where the magnitude is biggest. We can do this by looking for a maximum along a slice normal to the curve (non-maximum suppression). These points should form a curve. There are then two algorithmic issues: at which point is the maximum, and where is the next one? Non-Maximum Suppression • Suppress the pixels in ‘Gradient Magnitude Image’ which are not local maximum x, y if S x, y S x, y S x, y M x, y & S x, y S x, y 0 otherwise x, y x,y and x,y are the neighbors of x,y in x, y along the direction normal to an edge S Non-Maximum Suppression tan θ Sy Sx 2 3 1 0 : -0.4142 tan θ 0.4142 1 : 0.4142 tan θ 2.4142 2 : tan θ 2.4142 3 : - 2.4142 tan θ 0.4142 0 Non-Maximum Suppression S S x2 S y2 M Threshold 25 M Hysteresis Thresholding Hysteresis Thresholding • If the gradient at a pixel is above ‘High’, declare it an ‘edge pixel’ • If the gradient at a pixel is below ‘Low’, declare it a ‘non-edge-pixel’ • If the gradient at a pixel is between ‘Low’ and ‘High’ then declare it an ‘edge pixel’ if and only if it is connected to an ‘edge pixel’ directly or via pixels between ‘Low’ and ‘ High’ Hysteresis Thresholding M Threshold 25 M High 35 Low 15 an image its detected edges
© Copyright 2026 Paperzz