40
Edge detection –Part 2

Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Embed Size (px)

Citation preview

Page 1: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Edge detection –Part 2

Page 2: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian

Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long, containing a step edge. The right hand graph shows the response of a 1-D LoG filter with Gaussian = 3 pixels.

Page 3: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian (zero crossing detector) The starting point for the zero crossing detector is an image which has been filtered using the Laplacian of Gaussian filter.

However, zero crossings also occur at any place where the image intensity gradient starts increasing or starts decreasing, and this may happen at places that are not obviously edges. Often zero crossings are found in regions of very low gradient where the intensity gradient wobbles up and down around zero. Once the image has been LoG filtered, it only remains to detect the zero crossings. This can be done in several ways.

The simplest is to simply threshold the LoG output at zero, to produce a binary image where the boundaries between foreground and background regions represent the locations of zero crossing points. These boundaries can then be easily detected and marked in single pass, e.g. using some morphological operator. For instance, to locate all boundary points, we simply have to mark each foreground point that has at least one background neighbor.

Page 4: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian (zero crossing detector)

The problem with this technique is that will tend to bias the location of the zero crossing edge to either the light side of the edge, or the dark side of the edge, depending on whether it is decided to look for the edges of foreground regions or for the edges of background regions.

A better technique is to consider points on both sides of the threshold boundary, and choose the one with the lowest absolute magnitude of the Laplacian, which will hopefully be closest to the zero crossing.

Since the zero crossings generally fall in between two pixels in the LoG filtered image, an alternative output representation is an image grid which is spatially shifted half a pixel across and half a pixel down, relative to the original image. Such a representation is known as a dual lattice. This does not actually localize the zero crossing any more accurately, of course.

A more accurate approach is to perform some kind of interpolation to estimate the position of the zero crossing to sub-pixel precision.

Page 5: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Note that since the LoG is an isotropic filter , it is not possible to directly extract edge orientation information from the LoG output in the same way that it is for other edge detectors such as the Roberts Cross and Sobel operators.

An isotropic operator in an image processing context is one which applies equally well in all directions in an image, with no particular sensitivity or bias towards one particular set of directions (e.g. compass directions). A typical example is the zero crossing edge detector which responds equally well to edges in any orientation. Another example is Gaussian smoothing. It should be borne in mind that although an operator might be isotropic in theory, the actual implementation of it for use on a discrete pixel grid may not be perfectly isotropic. An example of this is a Gaussian smoothing filter with very small standard deviation on a square grid.

Page 6: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - ApplicationsThe behavior of the LoG zero crossing edge detector is largely governed by the standard deviation of the Gaussian used in the LoG filter. The higher this value is set, the more smaller features will be smoothed out of existence, and hence fewer zero crossings will be produced. Hence, this parameter can be set to remove unwanted detail or noise as desired. The idea that at different smoothing levels different sized features become prominent is referred to as `scale'.

This image contains detail at a number of different scales.

The image is the result of applying a LoG filter with Gaussian standard deviation 1.0.

Page 7: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - Applications

Note that in this and in the following LoG output images, the true output contains negative pixel values. For display purposes the graylevels have been offset so that displayed graylevel 128 corresponds to an actual value of zero, and rescaled to make the image variation clearer.

The image shows the zero crossings from this image. Note the large number of minor features detected, which are mostly due to noise or very faint detail. This smoothing corresponds to a fine `scale'.

Page 8: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - Applications

This image is the result of applying a LoG filter with Gaussian standard deviation 2.0 and

The image shows the zero crossings. Note that there are far fewer detected crossings, and that those that remain are largely due to recognizable edges in the image. The thin vertical stripes on the wall, for example, are clearly visible.

Page 9: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - Applications

This image is the output from a LoG filter with Gaussian standard deviation 3.0. This corresponds to quite a coarse `scale'

The is the zero crossings in this image. Note how only the strongest contours remain, due to the heavy smoothing. In particular, note how the thin vertical stripes on the wall no longer give rise to many zero crossings.

Page 10: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - Applications

Since the LoG filter is calculating a second derivative of the image, it is quite susceptible to noise, particularly if the standard deviation of the smoothing Gaussian is small. Thus it is common to see lots of spurious edges detected away from any obvious edges. One solution to this is to increase the smoothing of the Gaussian to preserve only strong edges. Another is to look at the gradient of the LoG at the zero crossing (i.e. the third derivative of the original image) and only keep zero crossings where this is above a certain threshold. This will tend to retain only the stronger edges, but it is sensitive to noise, since the third derivative will greatly amplify any high frequency noise in the image.

Page 11: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Laplacian of Gaussian - Applications

The image is similar to the image obtained with a standard deviation of 1.0, except that the zero crossing detector has been told to ignore zero crossings of shallow slope (in fact it ignores zero crossings where the pixel value difference across the crossing in the LoG output is less than 40). As a result, fewer spurious zero crossings have been detected. Note that,in this case, the zero crossings do not necessarily form closed contours.

The image shows the zero crossings from this image. Note the large number of minor features detected, which are mostly due to noise or very faint detail. This smoothing corresponds to a fine `scale'.

Page 12: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Use the second Derivatives for Enhancement

Background features can be recovered while still preserving the sharpening effect of Laplacian operation simply by adding the original and Laplacian image.

If the center coef. is negative

If the center coef. is positive

),(),(),( 2 yxfyxfyxfsharp

),(),(),( 2 yxfyxfyxfsharp

Page 13: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Marr (1982) has suggested that human visual systems use zero crossing detectors based on LoG filters at several different scales (Gaussian widths).

Page 14: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Difference of Gaussians ( DoG) OperatorIt is possible to approximate the LoG filter with a filter that is just the difference of two differently sized Gaussians. Such a filter is known as a DoG filter (short for `Difference of Gaussians').

A) For retinal ganglion cells and LGN neurons, the RF has a roughly circular , center-surround organisation. Two configurations are observed: one in which the RF center is responsive to bright stimuli ( ON-center) and the surround is responsive to dark stimuli, and the other (OFF-center) in which the respective polarities are reversed.

Page 15: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Difference of Gaussians ( DoG) Operator

The common feature of the two types of receptive fields is that the centre and surround regions are antagonistic. The DoG operator uses simple linear differences to model this centre-surround mechanism and the response R(x,t) is analogous to a measure of contrast of events happening between centre and surround regions of the operator. (see Figure 5)

Page 16: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Difference of Gaussians ( DoG) OperatorThe difference of Gaussian ( DoG) model is composed of the difference of two response functions that model the centre and surround mechanisms of retinal cells. Mathematically, the DoG operator is defined as

);();()( sscc GGDoG xxx (15)

where G is a two-dimensional Gaussian operator at x:

22

2||

22

1;

x

x

eG

Parameters c and s are standard deviations for centre and surround

Gaussian functions respectively. This Gaussian functions are weighted by integrated sensitivities c (for centre) and s (for the surround). The

response R(x,t), of the DoG filter to an input signal s(x,t) at x during time t is given by:

dxdytsDoGtR ,, wxwxw

(16)

Page 17: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

“On” events are extracted in parallel in several multiscale maps in temporal window of size T=2

Normalization

Competition among “on” maps

Time t Time t+1

Competition among “off” maps

Multi-agent reinforcement system

Location and scale of the most significant “on” events

Location and scale of the most significant “off” events

Evaluative feedback

“Off” events are extracted in parallel in several multiscale maps in temporal window of size T=2

Extending the DoG operator to detect changes in a sequence of images

Nc(x,t) – Nc(x,t-1)>=1

(for “on” center events)

Scale S represents a pair of values for c and s

Page 18: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detector

The mask we want to use for edge detection should have certain desirable characteristics, called Canny’s criteria:

1.       Good signal to noise ratio

2.       Good locality, i.e the edge should be detected where it actually is.

3.       Small number of false alarms, i.e. the maxima of the filter response should be mainly due to the presence of the true edges in the image rather than to noise.

Page 19: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detectorFor the smoothing step, the Canny detector employs a Gaussian low pass filter. The standard deviation, determines the width of the filter and hence the amount of smoothing. Let f(x,y) denote the input image. The result from convolving the image with Gaussian smoothing filter using separable filtering is an array of smoothed data. ),(),,(),( yxfyxGyxS where is the spread of the Gaussian and controls the degree of smoothing. The edge enhancement step simply involves calculation of the gradient vector at each pixel of the smoothed image.

),1(),1(),( yxSyxSyxg x )1,()1,(),( yxSyxSyxg y

22),( yx gggyxMagnitude

x

y

g

g1tan

Page 20: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detectorThe localization step has two stages: non-maximal suppression and hysteresis thresholding To identify edges , the broad ridges in the magnitude array must be thinned so that only the magnitudes at the points of greatest local change remain. As a result we receive a thinned edges.

Non maximal suppression thins the ridges of gradient magnitude in magnitude image area g(x,y) by suppressing all values along the line of the gradient that are not peak values of a ridge .

The algorithm begins by reducing the angle of the gradient (x,y) to one of the four sectors shown in the Figure. The angle is converted to a direction from 0 to 8. 0 meaning no direction, 1 is from 0 to 45 degrees, and 2 through eight follow counter clockwise. )],([ yxSectors

0

4590135

180

225 315

Page 21: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detectorThe algorithm passes a 3x 3 neighborhood across the Magnitude array g(x,y)

At each point , the center element g(x,y) of the neighborhood is compared with its two neighbors along the gradient direction. If the magnitude value at the center point is not greater than both of the neighbor magnitudes along the gradient direction, then g(x,y) is set zero. The values for the height of the ridge are retained in the non - maximal-suppressed magnitude.gsuppressed image = nms [g(x,y), s]

The typical procedure used to reduce the number of false edge fragments in the non maximal suppressed gradient magnitude is to apply a threshold to gsupressed image All values below the threshold are changed to

zero.

After nonmaxima suppression one ends up with an image which is zero everywhere except the local maxima points.

Page 22: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detector

There are four steps following the diagram:

1. Smoothing: using a gaussian smoothing operator

2. Gradient

3. Non-maximum suppression

4. Hysteresis threshold

Page 23: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detector

The effect of the Canny operator is determined by three parameters --- the width of the Gaussian kernel used in the smoothing phase, and the upper and lower thresholds used by the tracker. Increasing the width of the Gaussian kernel reduces the detector's sensitivity to noise, at the expense of losing some of the finer detail in the image. The localization error in the detected edges also increases slightly as the Gaussian width is increased.

Usually, the upper tracking threshold can be set quite high, and the lower threshold quite low for good results. Setting the lower threshold too high will cause noisy edges to break up. Setting the upper threshold too low increases the number of spurious and undesirable edge fragments appearing in the output.

Canny edge detector use double thresholding algorithm to detect and link edges.

Page 24: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detector

Using a Gaussian kernel with standard deviation 1.0 and upper and lower thresholds of 255 and 1, respectively, we obtain

The image is obtained by lowering the upper threshold to 128. The lower threshold is kept at 1 and the Gaussian standard deviation remains at 1.0. Many more faint edges are detected along with some short `noisy' fragments. Notice that the detail in the clown's hair is now picked out.

Page 25: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

The Canny edge detector

This image is obtained with the same thresholds as the previous image, but the Gaussian used has a standard deviation of 2.0. Much of the detail on the wall is no longer detected, but most of the strong edges remain. The edges also tend to be smoother and less noisy.

Page 26: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Unsharp FilterThe unsharp filter is a simple sharpening operator which derives its name from the fact that it enhances edges (and other high frequency components in an image) via a procedure which subtracts an unsharp, or smoothed, version of an image from the original image. The unsharp filtering technique is commonly used in the photographic and printing industries.Unsharp masking produces an edge image

from an input image via

Page 27: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Unsharp FilterWe can better understand the operation of the unsharp sharpening filter by examining its frequency response characteristics. If we have a signal as shown in Figure 2(a), subtracting away the lowpass component of that signal (as in Figure 2(b)), yields the highpass, or `edge', representation shown in Figure 2(c).

Figure 2:Calculating an edge image for unsharp filtering.

Page 28: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Unsharp FilterThis edge image can be used for sharpening if we add it back into the original signal, as shown in Figure 3.

Figure 3 Sharpening the original signal using the edge image.

Figure 4 The complete unsharp filtering operator

where k is a scaling constant. Reasonable values for k vary between 0.2 and 0.7, with

the larger values providing increasing amounts of sharpening.

Page 29: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Unsharp Filter -Guidelines for UseThe unsharp filter is implemented as a window-based operator, i.e. it relies on a convolution kernel to perform spatial filtering. It can be implemented using an appropriately defined lowpass filter to produce the smoothed version of an image, which is then pixel subtracted from the original image in order to produce a description of image edges, i.e. a highpassed image.

For example, consider the simple image object

whose strong edges have been slightly blurred by camera focus. In order to extract a sharpened view of the edges, we smooth this image using a mean filter (kernel size 3×3) and then subtract the smoothed result from the original image. The resulting image is

Page 30: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Unsharp FilterA more common way of implementing the unsharp mask is by using the negative Laplacian operator to extract the highpass information directly. See Figure .

Some unsharp masks for producing an edge image of this type are shown in Figure :

If the center coef. is negative

If the center coef. is positive

),(),(),( 2 yxfyxfyxfsharp

),(),(),( 2 yxfyxfyxfsharp

Page 31: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Adaptive Unsharp Masking A powerful technique for sharpening images in the presence of low noise levels is via an adaptive filtering algorithm. Here we look at a method of re-defining a highpass filter (such as the one shown in Figure 3) as the sum of a collection of edge directional kernels.

Figure3 Sharpening filter.

This filter can be re-written as 1/16 times the sum of the eight edge sensitive kernels shown in Figure 6. Figure

64Sharpening filter re-defined as eight edge directional kernels

Page 32: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Adaptive Unsharp MaskingAdaptive filtering using these kernels can be performed by filtering the image with each kernel, in turn, and then summing those outputs that exceed a threshold. As a final step, this result is added to the original image. (See Figure 7.)

This use of a threshold makes the filter adaptive in the sense that it overcomes the directionality of any single kernel by combining the results of filtering with a selection of kernels --- each of which is tuned to an edge direction inherent in the image.

Figure 7 Adaptive sharpening.

Page 33: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Line DetectionThe line detection operator consists of a convolution kernel tuned to detect the presence of lines of a particular width n, at a particular orientation . Figure shows a collection of four such kernels, which each respond to lines of single pixel width at the particular orientation shown

Figure :Four line detection kernels which respond maximally to horizontal, vertical

and oblique (+45 and - 45 degree) single pixel wide lines.

If Ri denotes the response of kernel i, we can apply each of these kernels across an image, and for any particular point, if Ri>Rj for all ji that point is more likely to contain a line whose orientation (and width) corresponds to that of kernel i.

Page 34: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Line Detection

These masks above are tuned for light lines against a dark background, and would give a big negative response to dark lines against a light background. If you are only interested in detecting dark lines against a light background, then you should negate the mask values. Alternatively, you might be interested in either kind of line, in which case, you could take the absolute value of the convolution output. In the discussion and examples below, we will use the kernels above without an absolute value.

Page 35: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Line Detection- Guidelines for UseThe result of applying the line detection operator, using the horizontal convolution kernel shown in Figure 1.a, is

There are two points of interest to note here

1. Notice that, because of way that the oblique lines (and some `vertical' ends of the horizontal bars) are represented on a square pixel grid, e.g.

Page 36: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Line Detection- Guidelines for Use

2. On an image such as this one, where the lines to be detected are wider than the kernel (i.e. the image lines are five pixels wide, while the kernel is tuned for a single width pixel), the line detector acts like an edge detector: the edges of the lines are found, rather than the lines themselves.

This latter fact might cause us to naively think that the image which gave rise to

contained a series of parallel lines rather than single thick ones.

Page 37: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

Line Detection- Guidelines for UseFor example, we can skeletonize the original (so as to obtain a representation of the original wherein most lines are a single pixel width), apply the horizontal line detector and then threshold the result.

Skeletonization is a process for reducing foreground regions in a binary image to a skeletal remnant that largely preserves the extent and connectivity of the original region while throwing away most of the original foreground pixels.

Page 38: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

More examples - Comparing Line detector and Canny operator

applying the Canny operator, we obtain

Page 39: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

More examples - Comparing Line detector and Canny operator

Applying the line detector yields

Page 40: Edge detection –Part 2. Laplacian of Gaussian Figure 1 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1-D image, 200 pixels long,

By smoothing the image before line detecting, we obtain the cleaner result

However, even with this preprocessing, the line detector still gives a poor result compared to the edge detector. This is true because there are few single pixel width lines in this image, and therefore the detector is responding to the other high spatial frequency image features (i.e. edges, thick lines and noise). (Note that in the previous example, the image contained the feature that the kernel was tuned for and therefore we were able to threshold away the weaker kernel response to edges.)