DSP in Image Processing
DSP in Image Processing
1.1
Introduction
An image is a two-dimensional signal whose intensity at any point is a function of two spatial variables [4]. We note x and y the spatial coordinates and f (x, y) the image intensity values. Examples: photographs, still video images, radar images, etc. An image sequence (e.g. television) is three-dimensional signal since the image intensity at any point is a function of the two spatial ones and the time. Each picture element or pixel represents a certain physical quantity. For instance, a photograph represents the luminances of various objects as seen by the camera. But an infrared image collects the temperature prole values of a scene. Image enhancement techniques emphasize specic image features to improve the visual perception of an image. Examples: contrast enhancement, edge detection, sharpening, zooming, etc. Edge detection is a problem of fundamental importance in image analysis. In typical images, edges characterize object boundaries and are therefore useful for segmentation, registration, and identication of objects in a scene. Localization, detection, and extraction of objects or details of a given type on the complex image have been long recognized as some of the most challenging problems in the eld of image processing. Edge-based segmentation is one of the earliest segmentation approaches and still remains very important. It relies on edges found in an image; these edges mark locations of discontinuities in gray level, colour, texture, etc. The nal aim is to group local edges into a contour picture where only edge chains with a correspondence to existing objects or image parts are present. The picture obtained utilizes one of the fundamental image attributes: coherency of the contour elements. 1
An edge is dened as a local variation of the image intensity f (x, y). An edge is a jump in intensity. Several type of edge proles are shown in gure 1.1. The gure 1.2 shows two examples of pictures, one from a cartoon with noise-free ideal edge, and the other is a photograph.
line
roof
step
noisy
Homer
Real Homer
Figure 1.2: Examples of images f (x, y) : ideal noise-free cartoon and real picture.
1.2
Sharpening by differentiation
As shown in gure 1.3, derivatives over an edge show signicant responses that are used for edge detection: (b) maxima of the rst derivative and (c) zero crossings in the second derivative.
Figure 1.3: (a) 1-D signal f (x), (b) its rst derivative fx (x) and (c) the second one fxx (x).
1.2.2
Second derivatives
When the rst derivative achieves a maximum, the second derivative is zero. For this reason, an alternative edge-detection strategy is to locate zeros of the second derivatives. The zeros of the Laplacian are used to locate edges: f (x, y) = fxx (x, y) + fyy (x, y) (1.1)
f (x, y)
| f (x, y)|
fx (x, y)
fy (x, y)
f (x, y)
in the spatial direction x and y. We note Hx (resp. Hy ) the spatial lter used to compute the rst derivative in the x direction (resp. y direction). fx = f Hx fy = f Hy
Figure 1.5: Computation of the Laplacian using only 1st derivative lters.
Those primitive lters can be used to computed the Laplacian of an image (cf. g. 1.5). The laplacian can be approximated by: f (x, y) f (x + 1, y) f (x 1, y) + f (x, y + 1) f (x, y 1) 4 f (x, y) Hence the laplacian of an image can be computed directly by convolution with the following lter: 0 1 0
L = 1 4 1 0 1 0 Depending of how the derivation is approximated, other lters Hx , Hy (Sobel, Prewitt, etc.) and L can be dened.
1.3.2
The previous methods are sensitive to the noise. In fact, edge lters are high pass-lters that enhance spatial high frequencies such as edges but also noise. One solution is to decrease the noise in the image by rst applying a smoothing lter. 1.3.2.1 Smoothing using a gaussian lter
A smoother instance f of the image f is obtained by convolution with the lter G: G(x, y) =
1 22 y x exp 22 exp 22
2 2
= G(x) G(y) G is a low pass-lter that removes very high frequencies due to noise. It is also separable since it can be decomposed in a product of two lters, one depending only on the variable x and the other depending only on y. 5
1.3.2.2
Computing fx corresponds to smooth in the y direction and to a derivation in the x direction. Computing fy corresponds to smooth in the x direction and a derivation in the y direction. These ltering processes are then well-suited to enhanced edges oriented in the x and y directions.
exp
1.3.4
Another method for edge detection is to apply difference of gaussian to an image. Two gaussian lters with different values of are applied in parallel to the image. Then the difference of the two smoothed instances f1 and f2 is computed. It can be shown that the DOG operator approximates the LOG one. Human visual system uses a similar method to detect edges.
1.3.5
clear all ; close all; % standard deviation of the gaussian filter std=1; % size of the convolution windows x=[-5*std:5*std]; y=[-5*std:5*std]; % filter: smoothing gaussian in the x direction
XG= exp(-x.^2/(2*std^2)) / (std*sqrt(2*pi)); % filter: smoothing gaussian in the x direction YG= exp(-y.^2/(2*std^2)) / (std*sqrt(2*pi)); % filter: derivative gaussian in the x direction XGx= -x.* exp(-x.^2/(2*std^2)) / (std^3*sqrt(2*pi)); % filter: derivative gaussian in the x direction
YGy=-y.* exp(-y.^2/(2*std^2)) / (std^3*sqrt(2*pi)); % filter: laplacian Mexican hat filter toto=(ones(length(x),1)*x.^2+ y.^2*ones(1,length(y)))/(std^2); LoG= (toto-2).*exp(-toto/2)/ (2*pi*std^4);
% reading an image I = imread(homer.png); % Ix : DroG Ix=conv2(I,XGx,same); Ix=conv2(Ix,YG,same); % Iy : DroG Iy=conv2(I,YGy,same); Iy=conv2(Iy,XG,same); % LoG LoG_I=conv2(I,LoG,same);
1.4
The edges can be segmented using the gradient or the laplacian of an image [2]. The edge contour can be extracted in three steps: 1. computing the magnitude of the gradient | f (x, y)|, 2. selecting the maxima of | f (x, y)| by thresholding: (x, y) contour if | f (x, y)| > s 7
When the magnitude changes a lot in the image due to noise, this technique is inefcient since no threshold can be set to nd the thin true contours. 3. To obtain thin contours, two solutions have been proposed: (a) Only local extrema of the gradient are kept. This is performed by selecting the pixel of highest magnitude of the gradient along its direction. (b) The detection of the contours is performed by locating the zero-crossings in the laplacian.
1.5
Applications
Figure 1.7 shows results of three basic images processing tools for parsing snooker videos. Since the main information relevant to the game happens when the snooker table is appearing, a colour segmentation is applied to detect its occurrence in the images. Then edge detection is performed to extract the contours of the table. At last, a Hough transform is computed allowing to select only straight edges.
Figure 1.7: Results of segmentation of snooker table using both colour and edge information (Work performed by Niall Rea and Hugh Denman, c Sigmedia Team).
1.5.2
Image enhancement/restoration
A well-known technique from photography to improve the visual quality of an image is to enhance the edges of the image. The technique is called Unsharp masking. Edge enhancement means rst isolating the edges in an image, amplifying them, and then adding them back into 9
the image. This leads immediately to the technique: f(x, y) = f (x, y) (k f (x, y)) (1.2)
The term k is the amplifying term and k > 0. Figure 1.8 shows a result of this technique on an astronomical image.
Original image
Bibliography
[1] D. Ballard and C. Brown. Computer Vision. Prentice Hall- Inc. Englewood Cliffs, New Jersey, 1982. Online at: http://www.dai.ed.ac.uk/homes/rbf/BANDB/. [2] R. Horaud and O. Monga. Vision par ordinateur- Outils fondamentaux. 2nd Editions Herms, 1995. Online at: http://www.inrialpes.fr/movi/people/Horaud/livre-hermes.html. [3] Anil Kokaram. Signals and systems handouts 3c1. Technical report, Trinity College, Dublin, Ireland, 2003. [4] S. K. Mitra. Digital Signal Processing- A Computer Based Approach. Mc Graw-Hill Electrical Engineering Series, 2001.
10