Images (we will, eventually, come back to imaging geometry. But, now that we know how images come from the world, we will examine operations on images). Edge Detection (with a sidelight introduction to linear, associative operators). (todays slides largely from David Forsyth and Cornelia Fermuller) Why edges? Convert a 2D image into a set of curves Extracts salient features of the scene ( invariant features ) More compact than pixels Origin of Edges Edge detection surface normal discontinuity depth discontinuity surface color discontinuity illumination discontinuity Edges are caused by a variety of factors How can you tell that a pixel is on an edge? 1
Edges. Found with Linear Filters applied to images. Linear Filters Linear Operator, from mathworld. An operator is said to be linear if, for every pair of functions f and g and scalar t, and General process: Form new image whose pixels are a weighted sum of original pixel values, using the same set of weights at each point. Properties Output is a linear function of the input Output is a shift-invariant function of the input (i.e. shift the input image two pixels to the left, the output is shifted two pixels to the left) Example: smoothing by averaging form the average of pixels in a neighbourhood Example: smoothing with a Gaussian form a weighted average of pixels in a neighbourhood Example: finding a derivative form a weighted average of pixels in a neighbourhood Edgel detection Edge is Where Change Occurs Difference operators (an edge is a change in intensity!) Change is measured by derivative in 1D Biggest change, derivative has maximum magnitude Or 2 nd derivative is zero. Parametric-model matchers (how do you describe your edges?) Image gradient as measure of change smooth images f(x,y) is pixel intensity at (continuous) location x,y The gradient of an image: The gradient points in the direction of most rapid change in intensity The discrete gradient How can we differentiate a digital image f[x,y]? Option 1: reconstruct a continuous image, then take gradient Option 2: take discrete derivative (finite difference) How would you implement this as a filter? The gradient direction is given by: how does this relate to the direction of the edge? The edge strength is given by the gradient magnitude 2
Finite differences Finite differences responding to noise Increasing noise -> (this is zero mean additive gaussian noise) Effects of noise Consider a single row or column of the image Plotting intensity as a function of position gives a signal sigma=1 Where is the edge? Finite differences and noise sigma=16 We re really good at ignoring noise? How? Finite difference filters respond strongly to noise obvious reason: image noise results in pixels that look very different from their neighbours Generally, the larger the noise the stronger the response What is to be done? 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 3
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 Solution: smooth first Convolution Represent these weights as an image, H H is usually called the kernel Operation is called convolution it s associative The filters look like little images: Result is: Convenient to think of i,j having both positive and negative values (ie, ranging from -2 2 Where is the edge? Look for peaks i Notice wierd order of indices all examples can be put in this form any shift-invariant linear operator can be expressed as a convolution. Example: Smoothing by Averaging Smoothing with a Gaussian Smoothing with an average actually doesn t compare at all well with a defocussed lens Most obvious difference is that a single point of light viewed in a defocussed lens looks like a fuzzy blob; but the averaging process would give a little square. A Gaussian gives a good model of a fuzzy blob 4
An Isotropic Gaussian Smoothing with a Gaussian The picture shows a smoothing kernel proportional to exp x2 + y 2 2σ 2 (which is a reasonable model of a circularly symmetric fuzzy blob) Convolution (Filtering), is associative Not Commutative, but associative Derivative theorem of convolution This saves us one operation: Differentiate (Smooth (image)). (Differentiate (Smooth) ) (image) Laplacian of Gaussian Consider 2D edge detection filters Laplacian of Gaussian Laplacian of Gaussian operator Gaussian derivative of Gaussian is the Laplacian operator: Where is the d? Zero-crossings of bottom h 5
Gradients and edges Points of sharp change in an image are interesting: change in reflectance change in object change in illumination noise Sometimes called edge points General strategy determine image gradient now mark points where gradient magnitude is particularly large wrt neighbours (ideally, curves of such points). There are three major issues: 1) The gradient magnitude at different scales is different; which s we choose? 2) The gradient magnitude is large along thick trail; how do we identify the significant points? 3) How do we link the relevant points up into curves? Smoothing and Differentiation Issue: noise smooth before differentiation two convolutions to smooth, then differentiate? actually, no - we can use a derivative of Gaussian filter because differentiation is convolution, and convolution is associative 1 pixel 3 pixels 7 pixels The scale of the smoothing filter affects derivative estimates, and also the semantics of the edges recovered. Optimal Edge Detection: Canny The Canny edge detector Assume: Linear filtering Additive iid Gaussian noise Edge detector should have: Good Detection. Filter responds to edge, not noise. Good Localization: detected edge near true edge. Single Response: one per edge. original image (Lena) 6
The Canny edge detector The Canny edge detector norm of the gradient thresholding The Canny edge detector thinning (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? Nonmaximum suppression At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values. Predicting the next edge point Assume the marked point is an edge point. Then we construct the tangent to the edge curve (which is normal to the gradient at that point) and use this to predict the next points (here either r or s). 7
Hysteresis Check that maximum value of gradient value is sufficiently large drop-outs? use hysteresis use a high threshold to start edge curves and a low threshold to continue them. fine scale high threshold coarse scale, high threshold Edge detection by subtraction coarse scale low threshold original 8
Edge detection by subtraction Edge detection by subtraction Why does this work? smoothed (5x5 Gaussian) smoothed original (scaled by 4, offset +128) filter demo Gaussian - image filter The Laplacian of Gaussian Gaussian delta function Another way to detect an extremal first derivative is to look for a zero second derivative Appropriate 2D analogy is rotation invariant the Laplacian Bad idea to apply a Laplacian without smoothing smooth with Gaussian, apply Laplacian this is the same as filtering with a Laplacian of Gaussian filter Now mark the zero points where there is a sufficiently large derivative, and enough contrast Laplacian of Gaussian sigma=4 Sidelight: Human neural responses that effectively compute edges. Slides from: Jay Myung, Ohio State University contrast=1 LOG zero crossings contrast=4 sigma=2 9
1. Receptive Field 2. On-center/OFF-surround RF The receptive field (RF) of a neuron is the area of retina cells that trigger activity of that neuron. 3. Edge Detector 4. Orientation Detector (Huble & Wiesel, 1959) Hypothetical Wiring Diagram 10