Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Digital Signal Processing. The Scientist and Engineers Guide. Steven W. Smith

.pdf
Скачиваний:
166
Добавлен:
02.05.2014
Размер:
7 Мб
Скачать
☆

Chapter 24Linear Image Processing

417

100 pixels

29 pixels

100 pixels

29 pixels

b. Target

a. Image to be searched

FIGURE 24-11

Target detection example. The problem is to search the 100×100 pixel image of George Washington, (a), for the target pattern, (b), the 29×29 pixel face. The optimal solution is correlation, which can be carried out by convolution.

before the correlation is performed. From the associative property of convolution, this is the same as applying the edge detection filter to the target signal twice, and leaving the original image alone. In actual practice, applying the edge detection 3×3 kernel only once is generally sufficient. This is how (b) is changed into (c) in Fig. 24-12. This makes (c) the PSF to be used in the convolution

Figure 24-13 illustrates the details of FFT convolution. In this example, we will convolve image (a) with image (b) to produce image (c). The fact that these images have been chosen and preprocessed to implement correlation is irrelevant; this is a flow diagram of convolution. The first step is to pad both signals being convolved with enough zeros to make them a power of two in size, and big enough to hold the final image. For instance, when images of 100×100 and 29×29 pixels are convolved, the resulting image will be 128×128 pixels. Therefore, enough zeros must be added to (a) and

(b) to make them each 128×128 pixels in size. If this isn't done, circular

a. Original

b. Rotated

c. Edge detection

FIGURE 24-12

Development of a correlation filter kernel. The target signal is shown in (a). In (b) it is rotated by 180E to undo the rotation inherent in convolution, allowing correlation to be performed. Applying an edge detection filter results in (c), the filter kernel used for this example.

418

The Scientist and Engineer's Guide to Digital Signal Processing

convolution takes place and the final image will be distorted. If you are having trouble understanding these concepts, go back and review Chapter 18, where the one-dimensional case is discussed in more detail.

The FFT algorithm is used to transform (a) and (b) into the frequency domain. This results in four 128×128 arrays, the real and imaginary parts of the two images being convolved. Multiplying the real and imaginary parts of (a) with the real and imaginary parts of (b), generates the real and imaginary parts of (c). (If you need to be reminded how this is done, see Eq. 9-1). Taking the Inverse FFT completes the algorithm by producing the final convolved image.

The value of each pixel in a correlation image is a measure of how well the target image matches the searched image at that point. In this particular example, the correlation image in (c) is composed of noise plus a single bright peak, indicating a good match to the target signal. Simply locating the brightest pixel in this image would specify the detected coordinates of the face. If we had not used the edge detection modification on the target signal, the peak would still be present, but much less distinct.

While correlation is a powerful tool in image processing, it suffers from a significant limitation: the target image must be exactly the same size and rotational orientation as the corresponding area in the searched image. Noise and other variations in the amplitude of each pixel are relatively unimportant, but an exact spatial match is critical. For example, this makes the method almost useless for finding enemy tanks in military reconnaissance photos, tumors in medical images, and handguns in airport baggage scans. One approach is to correlate the image multiple times with a variety of shapes and rotations of the target image. This works in principle, but the execution time will make you loose interest in a hurry.

A Closer Look at Image Convolution

Let's use this last example to explore two-dimensional convolution in more detail. Just as with one dimensional signals, image convolution can be viewed from either the input side or the output side. As you recall from Chapter 6, the input viewpoint is the best description of how convolution works, while the output viewpoint is how most of the mathematics and algorithms are written. You need to become comfortable with both these ways of looking at the operation.

Figure 24-14 shows the input side description of image convolution. Every pixel in the input image results in a scaled and shifted PSF being added to the output image. The output image is then calculated as the sum of all the contributing PSFs. This illustration show the contribution to the output image from the point at location [r,c] in the input image. The PSF is shifted such that pixel [0,0] in the PSF aligns with pixel [r,c] in the output image. If the PSF is defined with only positive indexes, such as in this example, the shifted PSF will be entirely to the lower-right of [r,c]. Don't

Chapter 24Linear Image Processing

419

Spatial Domain

 

Frequency Domain

a. Kernel, h[r,c]

 

 

 

 

 

 

H[r,c]

 

DFT

Re

Im

 

 

×

b. Image, x[r,c]

 

 

 

X[r,c]

 

DFT

Re

Im

 

 

 

 

 

 

=

c. Correlation, y[r,c]

 

 

Y[r,c]

IDFT

Re

Im

 

FIGURE 24-13

Flow diagram of FFT image convolution. The images in (a) and (b) are transformed into the frequency domain by using the FFT. These two frequency spectra are multiplied, and the Inverse FFT is used to move back into the spatial domain. In this example, the original images have been chosen and preprocessed to implement correlation through the action of convolution.

420

The Scientist and Engineer's Guide to Digital Signal Processing

 

Input image

Output image

column

0 c N-1

 

0

row

r

 

column

0 c N-1

 

0

row

r

 

N-1

N-1

FIGURE 24-14

Image convolution viewed from the input side. Each pixel in the input image contributes a scaled and shifted PSF to the output image. The output image is the sum of these contributions. The face is inverted in this illustration because this is the PSF we are using.

be confused by the face appearing upside down in this figure; this upside down face is the PSF we are using in this example (Fig. 24-13a). In the input side view, there is no rotation of the PSF, it is simply shifted.

Image convolution viewed from the output is illustrated in Fig. 24-15. Each pixel in the output image, such as shown by the sample at [r,c], receives a contribution from many pixels in the input image. The PSF is rotated by 180E around pixel [0,0], and then shifted such that pixel [0,0] in the PSF is aligned with pixel [r,c] in the input image. If the PSF only uses positive indexes, it will be to the upper-left of pixel [r,c] in the input image. The value of the pixel at [r,c] in the output image is found by multiplying the pixels in the rotated PSF with the corresponding pixels in the input image, and summing the products. This procedure is given by Eq. 24-3, and in the program of Table 24-1.

EQUATION 24-3

Image convolution. The images x[ , ] and h[ , ] are convolved to produce image, y[ , ]. The size of h[ , ] is M× M pixels, with the indexes running from 0 to M& 1 . In this equation, an individual pixel in the output image, y[r,c] , is calculated according to the output side view. The indexes j and k are used to loop through the rows and columns of h[ , ] to calculate the sum-of-products.

M &1 M&1

y [r,c ] ' j j h [k, j ] x [r &k, c &j ]

k ' 0 j'0

Notice that the PSF rotation resulting from the convolution has undone the rotation made in the design of the PSF. This makes the face appear upright in Fig. 24-15, allowing it to be in the same orientation as the pattern being detected in the input image. That is, we have successfully used convolution to implement correlation. Compare Fig. 24-13c with Fig. 24-15 to see how the bright spot in the correlation image signifies that the target has been detected.

Chapter 24Linear Image Processing

421

Input image

Output image

 

column

0 c N-1

 

0

row

r

 

column

0 c N-1

 

0

row

r

 

N-1

N-1

FIGURE 24-15

Image convolution viewed from the output side. Each pixel in the output signal is equal to the sum of the pixels in the rotated PSF multiplied by the corresponding pixels in the input image.

FFT convolution provides the same output image as the conventional convolution program of Table 24-1. Is the reduced execution time provided by FFT convolution really worth the additional program complexity? Let's take a closer look. Figure 24-16 shows an execution time comparison between conventional convolution using floating point (labeled FP), conventional convolution using integers (labeled INT), and FFT convolution using floating point (labeled FFT). Data for two different image sizes are presented, 512×512 and 128×128.

First, notice that the execution time required for FFT convolution does not depend on the size of the kernel, resulting in flat lines in this graph. On a 100 MHz Pentium personal computer, a 128×128 image can be convolved

100 CONVENTIONAL IMAGE CONVOLUTION

 

110 '

 

 

120

DIM X[99,99]

'holds the input image,

100×100 pixels

130 DIM H[28,28]

'holds the filter kernel,

29×29 pixels

140

DIM Y[127,127]

'holds the output image, 128×128 pixels

150 '

 

 

160

FOR R% = 0 TO 127

'loop through each row and column in the output

170

FOR C% = 0 TO 127

'image calculating the pixel value via Eq. 24-3

180 '

 

 

190

Y[R%,C%] = 0

'zero the pixel so it can be used as an accumulator

200 '

 

 

210

FOR J% = 0 TO 28

'multiply each pixel in the kernel by the corresponding

220

FOR K% = 0 TO 28

'pixel in the input image, and add to the accumulator

230

Y[R%,C%] = Y[R%,C%] + H[J%,K%] * X[R%-J%,C%-J%]

240

NEXT K%

 

 

250

NEXT J%

 

 

260 '

270 NEXT C%

280 NEXT R%

290 '

300 END

TABLE 24-1

422

The Scientist and Engineer's Guide to Digital Signal Processing

FIGURE 24-16

Execution time for image convolution. This graph shows the execution time on a 100 MHz Pentium processor for three image convolution methods: conventional convolution carried out with floating point math (FP), conventional convolution using integers (INT), and FFT convolution using floating point (FFT). The two sets of curves are for input image sizes of 512×512 and 128×128 pixels. Using FFT convolution, the time depends only on the image size, and not the size of the kernel. In contrast, conventional convolution depends on both the image and the kernel size.

 

5

 

 

 

 

 

 

 

FP

 

 

INT

 

 

 

 

 

 

 

 

 

 

 

 

FFT

 

 

4

 

 

 

512 × 512

 

(minutes)time

 

 

 

 

 

3

 

 

 

 

 

 

 

 

 

 

 

Execution

2

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

 

128 × 128

 

 

 

FP

 

INT

 

 

 

 

 

 

 

 

 

 

 

FFT

 

 

0

 

 

 

 

 

 

0

10

20

30

40

50

Kernel width (pixels)

in about 15 seconds using FFT convolution, while a 512×512 image requires more than 4 minutes. Adding up the number of calculations shows that the execution time for FFT convolution is proportional to N 2 Log2(N) , for an N× N image. That is, a 512×512 image requires about 20 times as long as a 128×128 image.

Conventional convolution has an execution time proportional to N 2M 2 for an N× N image convolved with an M× M kernel. This can be understood by examining the program in Table 24-1. In other words, the execution time for conventional convolution depends very strongly on the size of the kernel used. As shown in the graph, FFT convolution is faster than conventional convolution using floating point if the kernel is larger than about 10×10 pixels. In most cases, integers can be used for conventional convolution, increasing the breakeven point to about 30×30 pixels. These break-even points depend slightly on the size of the image being convolved, as shown in the graph. The concept to remember is that FFT convolution is only useful for large filter kernels.

CHAPTER

Special Imaging Techniques

25

This chapter presents four specific aspects of image processing. First, ways to characterize the spatial resolution are discussed. This describes the minimum size an object must be to be seen in an image. Second, the signal-to-noise ratio is examined, explaining how faint an object can be and still be detected. Third, morphological techniques are introduced. These are nonlinear operations used to manipulate binary images (where each pixel is either black or white). Fourth, the remarkable technique of computed tomography is described. This has revolutionized medical diagnosis by providing detailed images of the interior of the human body.

Spatial Resolution

Suppose we want to compare two imaging systems, with the goal of determining which has the best spatial resolution. In other words, we want to know which system can detect the smallest object. To simplify things, we would like the answer to be a single number for each system. This allows a direct comparison upon which to base design decisions. Unfortunately, a single parameter is not always sufficient to characterize all the subtle aspects of imaging. This is complicated by the fact that spatial resolution is limited by two distinct but interrelated effects: sample spacing and sampling aperture size. This section contains two main topics: (1) how a single parameter can best be used to characterize spatial resolution, and (2) the relationship between sample spacing and sampling aperture size.

Figure 25-1a shows profiles from three circularly symmetric PSFs: the pillbox, the Gaussian, and the exponential. These are representative of the PSFs commonly found in imaging systems. As described in the last chapter, the pillbox can result from an improperly focused lens system. Likewise, the Gaussian is formed when random errors are combined, such as viewing stars through a turbulent atmosphere. An exponential PSF is generated when electrons or x-rays strike a phosphor layer and are converted into

423

424

The Scientist and Engineer's Guide to Digital Signal Processing

Amplitude

1.25

 

1.25

 

a. PSF

b. MTF

 

 

1.00

1.00

 

 

 

P

 

 

0.50

Amplitude 0.50

 

 

0.75

0.75

 

 

 

 

G

P

 

E

 

 

 

 

0.25

 

 

 

 

 

 

 

E

0.25

 

 

 

 

 

 

 

 

 

 

 

G

 

 

 

 

 

0.00

 

 

 

 

 

 

 

0.00

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

0

0.5

1

1.5

2

Distance

Spatial frequency (lp per unit distance)

FIGURE 25-1

FWHM versus MTF. Figure (a) shows profiles of three PSFs commonly found in imaging systems: (P) pillbox,

(G) Gaussian, and (E) exponential. Each of these has a FWHM of one unit. The corresponding MTFs are shown in (b). Unfortunately, similar values of FWHM do not correspond to similar MTF curves.

light. This is used in radiation detectors, night vision light amplifiers, and CRT displays. The exact shape of these three PSFs is not important for this discussion, only that they broadly represent the PSFs seen in real world applications.

The PSF contains complete information about the spatial resolution. To express the spatial resolution by a single number, we can ignore the shape of the PSF and simply measure its width. The most common way to specify this is by the Full-Width-at-Half-Maximum (FWHM) value. For example, all the PSFs in

(a) have an FWHM of 1 unit.

Unfortunately, this method has two significant drawbacks. First, it does not match other measures of spatial resolution, including the subjective judgement of observers viewing the images. Second, it is usually very difficult to directly measure the PSF. Imagine feeding an impulse into an imaging system; that is, taking an image of a very small white dot on a black background. By definition, the acquired image will be the PSF of the system. The problem is, the measured PSF will only contain a few pixels, and its contrast will be low. Unless you are very careful, random noise will swamp the measurement. For instance, imagine that the impulse image is a 512×512 array of all zeros except for a single pixel having a value of 255. Now compare this to a normal image where all of the 512×512 pixels have an average value of about 128. In loose terms, the signal in the impulse image is about 100,000 times weaker than a normal image. No wonder the signal-to-noise ratio will be bad; there's hardly any signal!

A basic theme throughout this book is that signals should be understood in the domain where the information is encoded. For instance, audio signals should be dealt with in the frequency domain, while image signals should be handled in the spatial domain. In spite of this, one way to measure image resolution is by looking at the frequency response. This goes against the fundamental

Chapter 25Special Imaging Techniques

425

philosophy of this book; however, it is a common method and you need to become familiar with it.

Taking the two-dimensional Fourier transform of the PSF provides the twodimensional frequency response. If the PSF is circularly symmetric, its frequency response will also be circularly symmetric. In this case, complete information about the frequency response is contained in its profile. That is, after calculating the frequency domain via the FFT method, columns 0 to N/2 in row 0 are all that is needed. In imaging jargon, this display of the frequency response is called the Modulation Transfer Function (MTF). Figure 25-1b shows the MTFs for the three PSFs in (a). In cases where the PSF is not circularly symmetric, the entire two-dimensional frequency response contains information. However, it is usually sufficient to know the MTF curves in the vertical and horizontal directions (i.e., columns 0 to N/2 in row 0, and rows 0 to N/2 in column 0). Take note: this procedure of extracting a row or column from the two-dimensional frequency spectrum is not equivalent to taking the one-dimensional FFT of the profiles shown in (a). We will come back to this issue shortly. As shown in Fig. 25-1, similar values of FWHM do not correspond to similar MTF curves.

Figure 25-2 shows a line pair gauge, a device used to measure image resolution via the MTF. Line pair gauges come in different forms depending on the particular application. For example, the black and white pattern shown in this figure could be directly used to test video cameras. For an x-ray imaging system, the ribs might be made from lead, with an x-ray transparent material between. The key feature is that the black and white lines have a closer spacing toward one end. When an image is taken of a line pair gauge, the lines at the closely spaced end will be blurred together, while at the other end they will be distinct. Somewhere in the middle the lines will be just barely separable. An observer looks at the image, identifies this location, and reads the corresponding resolution on the calibrated scale.

FIGURE 25-2

Line pair gauge. The line pair gauge is a tool used to measure the resolution of imaging systems. A series of black and white ribs move together, creating a continuum of spatial frequencies. The resolution of a system is taken as the frequency where the eye can no longer distinguish the individual ribs. This example line pair gauge is shown several times larger than the calibrated scale indicates.

line pairs / mm

40

30

20

15

10

7

5

4

3

a. Example profile at 12 lp/mm

250

 

 

 

 

200

 

 

 

 

value

 

 

 

 

150

 

 

 

 

Pixel

 

 

 

 

100

 

 

 

 

50

 

 

 

 

0

 

 

 

 

0

60

120

180

240

 

Pixel number

 

 

b. Example profile at 3 lp/mm

250

 

 

 

 

200

 

 

 

 

value

 

 

 

 

150

 

 

 

 

Pixel

 

 

 

 

100

 

 

 

 

50

 

 

 

 

0

 

 

 

 

0

60

120

180

240

2

Pixel number

426

The Scientist and Engineer's Guide to Digital Signal Processing

The way that the ribs blur together is important in understanding the limitations of this measurement. Imagine acquiring an image of the line pair gauge in Fig. 25-2. Figures (a) and (b) show examples of the profiles at low and high spatial frequencies. At the low frequency, shown in (b), the curve is flat on the top and bottom, but the edges are blurred, At the higher spatial frequency, (a), the amplitude of the modulation has been reduced. This is exactly what the MTF curve in Fig. 25-1b describes: higher spatial frequencies are reduced in amplitude. The individual ribs will be distinguishable in the image as long as the amplitude is greater than about 3% to 10% of the original height. This is related to the eye's ability to distinguish the low contrast difference between the peaks and valleys in the presence of image noise.

A strong advantage of the line pair gauge measurement is that it is simple and fast. The strongest disadvantage is that it relies on the human eye, and therefore has a certain subjective component. Even if the entire MTF curve is measured, the most common way to express the system resolution is to quote the frequency where the MTF is reduced to either 3%, 5% or 10%. Unfortunately, you will not always be told which of these values is being used; product data sheets frequently use vague terms such as "limiting resolution." Since manufacturers like their specifications to be as good as possible (regardless of what the device actually does), be safe and interpret these ambiguous terms to mean 3% on the MTF curve.

A subtle point to notice is that the MTF is defined in terms of sine waves, while the line pair gauge uses square waves. That is, the ribs are uniformly dark regions separated by uniformly light regions. This is done for manufacturing convenience; it is very difficult to make lines that have a sinusoidally varying darkness. What are the consequences of using a square wave to measure the MTF? At high spatial frequencies, all frequency components but the fundamental of the square wave have been removed. This causes the modulation to appear sinusoidal, such as is shown in Fig. 25-2a. At low frequencies, such as shown in Fig. 25-2b, the wave appears square. The fundamental sine wave contained in a square wave has an amplitude of 4/B ' 1.27 times the amplitude of the square wave (see Table 13-10). The result: the line pair gauge provides a slight overestimate of the true resolution of the system, by starting with an effective amplitude of more than pure black to pure white. Interesting, but almost always ignored.

Since square waves and sine waves are used interchangeably to measure the MTF, a special terminology has arisen. Instead of the word "cycle," those in imaging use the term line pair (a dark line next to a light line). For example, a spatial frequency would be referred to as 25 line pairs per millimeter, instead of 25 cycles per millimeter.

The width of the PSF doesn't track well with human perception and is difficult to measure. The MTF methods are in the wrong domain for understanding how resolution affects the encoded information. Is there a more favorable alternative? The answer is yes, the line spread function (LSF) and the edge response. As shown in Fig. 25-3, the line spread

Соседние файлы в предмете Электроника