Você está na página 1de 18

M.Phil.

(Information Technology)

ITEC 804 Computer Vision

Laplacian/Laplacian of Gaussian

Common Names: Laplacian, Laplacian of Gaussian, LoG, Marr Filter

Brief Description
The Laplacian is a 2-D isotropic measure of the 2nd spatial derivative of an image.
The Laplacian of an image highlights regions of rapid intensity change and is
therefore often used for edge detection (see zero crossing edge detectors). The
Laplacian is often applied to an image that has first been smoothed with something
approximating a Gaussian smoothing filter in order to reduce its sensitivity to
noise, and hence the two variants will be described together here. The operator
normally takes a single graylevel image as input and produces another graylevel
image as output.

How It Works
The Laplacian L(x,y) of an image with pixel intensity values I(x,y) is given by:

This can be calculated using a convolution filter.


Since the input image is represented as a set of discrete pixels, we have to find a
discrete convolution kernel that can approximate the second derivatives in the
definition of the Laplacian. Two commonly used small kernels are shown in Figure

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

1.

Figure 1 Two commonly used discrete approximations to the Laplacian filter.


(Note, we have defined the Laplacian using a negative peak because this is more
common; however, it is equally valid to use the opposite sign convention.)
Using one of these kernels, the Laplacian can be calculated using standard
convolution methods.
Because these kernels are approximating a second derivative measurement on the
image, they are very sensitive to noise. To counter this, the image is often Gaussian
smoothed before applying the Laplacian filter. This pre-processing step reduces the
high frequency noise components prior to the differentiation step.
In fact, since the convolution operation is associative, we can convolve the
Gaussian smoothing filter with the Laplacian filter first of all, and then convolve
this hybrid filter with the image to achieve the required result. Doing things this
way has two advantages:
Since both the Gaussian and the Laplacian kernels are usually much smaller
than the image, this method usually requires far fewer arithmetic operations.
The LoG (`Laplacian of Gaussian') kernel can be precalculated in advance
so only one convolution needs to be performed at run-time on the image.
The 2-D LoG function centered on zero and with Gaussian standard deviation
has the form:

and is shown in Figure 2.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Figure 2 The 2-D Laplacian of Gaussian (LoG) function. The x and y axes are
marked in standard deviations ( ).
A discrete kernel that approximates this function (for a Gaussian
in Figure 3.

= 1.4) is shown

Figure 3 Discrete approximation to LoG function with Gaussian

= 1.4

Note that as the Gaussian is made increasingly narrow, the LoG kernel becomes the
same as the simple Laplacian kernels shown in Figure 1. This is because smoothing
with a very narrow Gaussian ( < 0.5 pixels) on a discrete grid has no effect.
Hence on a discrete grid, the simple Laplacian can be seen as a limiting case of the
LoG for narrow Gaussians.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Guidelines for Use


The LoG operator calculates the second spatial derivative of an image. This means
that in areas where the image has a constant intensity (i.e. where the intensity
gradient is zero), the LoG response will be zero. In the vicinity of a change in
intensity, however, the LoG response will be positive on the darker side, and
negative on the lighter side. This means that at a reasonably sharp edge between
two regions of uniform but different intensities, the LoG response will be:
zero at a long distance from the edge,
positive just to one side of the edge,
negative just to the other side of the edge,
zero at some point in between, on the edge itself.
Figure 4 illustrates the response of the LoG to a step edge.

Figure 4 Response of 1-D LoG filter to a step edge. The left hand graph shows a 1D 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.
By itself, the effect of the filter is to highlight edges in an image.
For example,

is a simple image with strong edges.


Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

The image

is the result of applying a LoG filter with Gaussian = 1.0. A 77 kernel was used.
Note that the output contains negative and non-integer values, so for display
purposes the image has beennormalized to the range 0 - 255.
If a portion of the filtered, or gradient, image is added to the original image, then
the result will be to make any edges in the original image much sharper and give
them more contrast. This is commonly used as an enhancement technique in
remote sensing applications.
To see this we start with

which is a slightly blurry image of a face.


The image

is the effect of applying an LoG filter with Gaussian


kernel.

= 1.0, again using a 77

Finally,

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

is the result of combining (i.e. subtracting) the filtered image and the original
image. Note that the filtered image had to be suitable scaled before combining in
order to produce a sensible enhancement. Also, it may be necessary to translate the
filtered image by half the width of the convolution kernel in both
the x and y directions in order to register the images correctly.
The enhancement has made edges sharper but has also increased the effect of
noise. If we simply filter the image with a Laplacian (i.e. use a LoG filter with a
very narrow Gaussian) we obtain

Performing edge enhancement using this sharpening image yields the noisy result

(Note that unsharp filtering may produce an equivalent result since it can be
defined by adding the negative Laplacian image (or any suitable edge image) onto
the original.) Conversely, widening the Gaussian smoothing component of the
operator can reduce some of this noise, but, at the same time, the enhancement
effect becomes less pronounced.
The fact that the output of the filter passes through zero at edges can be used to
detect those edges. See the section on zero crossing edge detection.
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 theRoberts Cross and Sobel operators.
Convolving with a kernel such as the one shown in Figure 3 can very easily
produce output pixel values that are much larger than any of the input pixels
values, and which may be negative. Therefore it is important to use an image type
(e.g. floating point) that supports negative numbers and a large range in order to
avoid overflow or saturation. The kernel can also be scaled down by a constant
factor in order to reduce the range of output values.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Common Variants
It 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').
As an aside it has been suggested (Marr 1982) that LoG filters (actually DoG
filters) are important in biological visual processing.
An even cruder approximation to the LoG (but much faster to compute) is the DoB
filter (`Difference of Boxes'). This is simply the difference between two mean
filters of different sizes. It produces a kind of squared-off approximate version of
the LoG.

Interactive Experimentation
You can interactively experiment with the Laplacian operator by clicking here.
You can interactively experiment with the Laplacian of Gaussian operator by
clicking here.

Exercises
1. Try the effect of LoG filters using different width Gaussians on the image

What is the general effect of increasing the Gaussian width? Notice


particularly the effect on features of different sizes and thicknesses.
2. Construct a LoG filter where the kernel size is much too small for the
chosen Gaussian width (i.e. the LoG becomes truncated). What is the effect
on the output? In particular what do you notice about the LoG output in
different regions each of uniform but different intensities?
3. Devise a rule to determine how big an LoG kernel should be made in
relation to the of the underlying Gaussian if severe truncation is to be
avoided.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

4. If you were asked to construct an edge detector that simply looked for peaks
(both positive and negative) in the output from an LoG filter, what would
such a detector produce as output from a single step edge?

References
R. Haralick and L. Shapiro Computer and Robot Vision, Vol. 1, Addison-Wesley
Publishing Company, 1992, pp 346 - 351.
B. Horn Robot Vision, MIT Press, 1986, Chap. 8.
D. Marr Vision, Freeman, 1982, Chap. 2, pp 54 - 78.
D. Vernon Machine Vision, Prentice-Hall, 1991, pp 98 - 99, 214.

Local Information
Specific information about this operator may be found here.
More general advice about the local HIPR installation is available in the Local
Information introductory section.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Gaussian Smoothing

Common Names: Gaussian smoothing

Brief Description
The Gaussian smoothing operator is a 2-D convolution operator that is used to
`blur' images and remove detail and noise. In this sense it is similar to the mean
filter, but it uses a different kernelthat represents the shape of a Gaussian (`bellshaped') hump. This kernel has some special properties which are detailed below.

How It Works
The Gaussian distribution in 1-D has the form:

where is the standard deviation of the distribution. We have also assumed that the
distribution has a mean of zero (i.e. it is centered on the line x=0). The distribution
is illustrated in Figure 1.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Figure 1 1-D Gaussian distribution with mean 0 and =1


In 2-D, an isotropic (i.e. circularly symmetric) Gaussian has the form:

This distribution is shown in Figure 2.

Figure 2 2-D Gaussian distribution with mean (0,0) and =1

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

The idea of Gaussian smoothing is to use this 2-D distribution as a `point-spread'


function, and this is achieved by convolution. Since the image is stored as a
collection of discrete pixels we need to produce a discrete approximation to the
Gaussian function before we can perform the convolution. In theory, the Gaussian
distribution is non-zero everywhere, which would require an infinitely large
convolution kernel, but in practice it is effectively zero more than about three
standard deviations from the mean, and so we can truncate the kernel at this point.
Figure 3 shows a suitable integer-valued convolution kernel that approximates a
Gaussian with a of 1.0. It is not obvious how to pick the values of the mask to
approximate a Gaussian. One could use the value of the Gaussian at the centre of a
pixel in the mask, but this is not accurate because the value of the Gaussian varies
non-linearly across the pixel. We integrated the value of the Gaussian over the
whole pixel (by summing the Gaussian at 0.001 increments). The integrals are not
integers: we rescaled the array so that the corners had the value 1. Finally, the 273
is the sum of all the values in the mask.

Figure 3 Discrete approximation to Gaussian function with =1.0


Once a suitable kernel has been calculated, then the Gaussian smoothing can be
performed using standard convolution methods. The convolution can in fact be
performed fairly quickly since the equation for the 2-D isotropic Gaussian shown
above is separable into x and y components. Thus the 2-D convolution can be
performed by first convolving with a 1-D Gaussian in the x direction, and then
convolving with another 1-D Gaussian in the y direction. (The Gaussian is in fact
the only completely circularly symmetric operator which can be decomposed in
such a way.) Figure 4 shows the 1-D x component kernel that would be used to
produce the full kernel shown in Figure 3 (after scaling by 273, rounding and
truncating one row of pixels around the boundary because they mostly have the
value 0. This reduces the 7x7 matrix to the 5x5 shown above.). The y component is
exactly the same but is oriented vertically.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Figure 4 One of the pair of 1-D convolution kernels used to calculate the full
kernel shown in Figure 3 more quickly.
A further way to compute a Gaussian smoothing with a large standard deviation is
to convolve an image several times with a smaller Gaussian. While this is
computationally complex, it can have applicability if the processing is carried out
using a hardware pipeline.
The Gaussian filter not only has utility in engineering applications. It is also
attracting attention from computational biologists because it has been attributed
with some amount of biological plausibility, e.g. some cells in the visual pathways
of the brain often have an approximately Gaussian response.

Guidelines for Use


The effect of Gaussian smoothing is to blur an image, in a similar fashion to
the mean filter. The degree of smoothing is determined by the standard deviation of
the Gaussian. (Larger standard deviation Gaussians, of course, require larger
convolution kernels in order to be accurately represented.)
The Gaussian outputs a `weighted average' of each pixel's neighborhood, with the
average weighted more towards the value of the central pixels. This is in contrast
to the mean filter's uniformly weighted average. Because of this, a Gaussian
provides gentler smoothing and preserves edges better than a similarly sized mean
filter.
One of the principle justifications for using the Gaussian as a smoothing filter is
due to its frequency response. Most convolution-based smoothing filters act as
lowpass frequency filters. This means that their effect is to remove high spatial
frequency components from an image. The frequency response of a convolution
filter, i.e. its effect on different spatial frequencies, can be seen by taking the
Fourier transform of the filter. Figure 5 shows the frequency responses of a 1-D
mean filter with width 5 and also of a Gaussian filter with = 3.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Figure 5 Frequency responses of Box (i.e. mean) filter (width 5 pixels) and
Gaussian filter ( = 3 pixels). The spatial frequency axis is marked in cycles per
pixel, and hence no value above 0.5 has a real meaning.
Both filters attenuate high frequencies more than low frequencies, but the mean
filter exhibits oscillations in its frequency response. The Gaussian on the other
hand shows no oscillations. In fact, the shape of the frequency response curve is
itself (half a) Gaussian. So by choosing an appropriately sized Gaussian filter we
can be fairly confident about what range of spatial frequencies are still present in
the image after filtering, which is not the case of the mean filter. This has
consequences for some edge detection techniques, as mentioned in the section on
zero crossings. (The Gaussian filter also turns out to be very similar to the optimal
smoothing filter for edge detection under the criteria used to derive the Canny edge
detector.)
We use

to illustrate the effect of smoothing with successively larger and larger Gaussian
filters.
The image

shows the effect of filtering with a Gaussian of

= 1.0 (and kernel size 55).

The image

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

shows the effect of filtering with a Gaussian of

ITEC 804 Computer Vision

= 2.0 (and kernel size 99).

The image

shows the effect of filtering with a Gaussian of

= 4.0 (and kernel size 1515).

We now consider using the Gaussian filter for noise reduction. For example,
consider the image

which has been corrupted by Gaussian noise with a mean of zero and
Smoothing this with a 55 Gaussian yields

= 8.

(Compare this result with that achieved by the mean and median filters.)
Salt and pepper noise is more challenging for a Gaussian filter. Here we will
smooth the image

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

which has been corrupted by 1% salt and pepper noise (i.e. individual bits have
been flipped with probability 1%). The image

shows the result of Gaussian smoothing (using the same convolution as above).
Compare this with the original

Notice that much of the noise still exists and that, although it has decreased in
magnitude somewhat, it has been smeared out over a larger spatial region.
Increasing the standard deviation continues to reduce/blur the intensity of the
noise, but also attenuates high frequency detail (e.g. edges) significantly, as shown
in

This type of noise is better reduced using median filtering, conservative


smoothing or Crimmins Speckle Removal.

Interactive Experimentation
You can interactively experiment with this operator by clicking here.

Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

Exercises
1. Starting from the Gaussian noise (mean 0,

= 13) corrupted image

compute both mean filter and Gaussian filter smoothing at various scales,
and compare each in terms of noise removal vs loss of detail.
2. At how many standard deviations from the mean does a Gaussian fall to 5%
of its peak value? On the basis of this suggest a suitable square kernel size
for a Gaussian filter with = s.
3. Estimate the frequency response for a Gaussian filter by Gaussian
smoothing an image, and taking its Fourier transform both before and
afterwards. Compare this with the frequency response of a mean filter.
4. How does the time taken to smooth with a Gaussian filter compare with the
time taken to smooth with a mean filter for a kernel of the same size? Notice
that in both cases the convolution can be speeded up considerably by
exploiting certain features of the kernel.

References
E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press,
1990, pp 42 - 44.
R. Gonzalez and R. Woods Digital Image Processing, Addison-Wesley
Publishing Company, 1992, p 191.
R. Haralick and L. Shapiro Computer and Robot Vision, Addison-Wesley
Publishing Company, 1992, Vol. 1, Chap. 7.
B. Horn Robot Vision, MIT Press, 1986, Chap. 8.
D. Vernon Machine Vision, Prentice-Hall, 1991, pp 59 - 61, 214.

Local Information
Specific information about this operator may be found here.
Prepared by: Zeeshan Hyder Bhatti

M.Phil. (Information Technology)

ITEC 804 Computer Vision

More general advice about the local HIPR installation is available in the Local
Information introductory section.

Prepared by: Zeeshan Hyder Bhatti

Você também pode gostar