Sharp Image Point

Seen Spread

Outside the Atmosphere Function

Soft Image Seen

Through the Telescope

Sharp Image Point

Seen Spread

Outside the Atmosphere Function

Soft Image Seen

Figure 14.4 In two dimensions, the image and the convolution kernel have a more familiar look. The sharp image is just an area of the sky, and the kernel representing the point-spread function is typical of a well-focused star image. The resulting soft edge looks like the limb of the Moon in a typical CCD image.

age processing. As we shall see below, this versatile neighborhood operation can smooth or sharpen images, detect edges, and produce a variety of effects that aid us in extracting all the information present in the image.

Convolution in two dimensions is defined in much the same way as it is in one dimension; i.e., as the sum of the product of the kernel with the pixel in the corresponding location in the image:

This operation may be a bit difficult to visualize. Imagine the convolution kernel superimposed on the image array, one pixel at a time for the entire image, with the zero-zero element of the kernel directly over the current pixel. Each element in the kernel is multiplied by the pixel value directly under it; the products summed and then divided by the sum of the elements in the kernel. This operation is repeated for each pixel in the entire image.

Convolution kernels come in all sizes. In the following sections, you will see examples of 3 x 3 kernels (r = 1), 5 x 5 kernels (r = 2), and 7x7 kernels (r = 3). Using functions to generate separable kernels, however, it is feasible to create and apply kernels of much greater size. Furthermore, they need not have equal dimensions, so kernels of 3 x 5 elements or 1 x 9 elements are perfectly legitimate.

Finally, the kernel need not be filled: zeros can hold as many locations in it as the user wishes. From the definition of convolution, it is clear that the zero-value elements have no effect on the outcome. Kernels with even dimensions (i.e., 2

Original Image New Image

Figure 14.5 To compute a two-dimensional digital convolution, the kernel sweeps right to left and top to bottom, visiting in turn each pixel in the original image. Each pixel in the original image and neighboring pixels are multiplied by the corresponding elements from the kernel, summed, and normalized.

Figure 14.5 To compute a two-dimensional digital convolution, the kernel sweeps right to left and top to bottom, visiting in turn each pixel in the original image. Each pixel in the original image and neighboring pixels are multiplied by the corresponding elements from the kernel, summed, and normalized.

x 4) can be treated as ones with odd dimensions (3 x 5) having zero-padded rows or columns.

Convolution draws heavily on computing resources. To convolve an image 512x512 pixels with a convolution kernel that is 7 x 7 elements requires 7 x 7 x 512x512 = 12 million multiplications and 12 million additionsâ€”with a hundred thousand divisions thrown in as small change. In the early days of image processing, it took a mainframe to carry out such major operations. Microcomputers now handle the job with dispatch.

The following pseudocode shows an algorithm for carrying out a two-dimensional convolution and normalization by the sum of the elements in the kernel. The first step is to compute the sum of the kernel:

FOR j = -r TO r FOR i = -r TO r ksum = ksum + k(i,j) NEXT i NEXT j

The convolution routine that follows is computationally intensive because multiplication and addition steps are carried out inside four nested loops:

FOR y = r TO ymax - r FOR x = r TO xmax - r FOR j = -r TO r FOR i = -r TO r new(x,y) = new(x,y)

NEXT i NEXT j

IF ksumoO THEN new(x,y) = new(x,y) / ksum 374 Handbook of Astronomical Image Processing

NEXT x

NEXT y

If the sum of elements in the kernel is zero, normalization is impossible.

The resulting image may have pixels with negative values. To display the result as a gray-value image, the user can add a constant to all of the pixel values in it. Many image-processing packages allow the user to specify a value to take the place of ksum or a constant to add to the resulting pixel value.

The algorithm above does not evaluate the edge pixels for the destination image because there are no pixels in the old image for the corresponding elements in the kernel. To compute values for edge pixels, the kernel can be truncated so as not to extend past the edge of the old image, a sum for the overlapping section computed, and a result assigned to the edge pixel in the destination image.

Because it is a fundamentally simple scheme of multiplications and additions, convolution shares many of the properties of those operations. These properties lead to extremely versatile ways to carry out convolution with images. In particular, convolution is a linear shift-invariant (LSI) process. It is these two properties that distinguish convolution kernels discussed in this chapter from the nonlinear neighborhood operators discussed in the next one.

Linearity. This property means that convolution kernels and the images they operate on can be separated, computed, and then added to produce the same new image as that derived from computing them together. At the most basic level, suppose that you separated an image into a large number of images, each containing just one pixel, and computed the convolution for each one-pixel image. After summing the images into one, you will have the same new image you would have obtained if you had computed the convolution of the complete image. Although this seems a bit esoteric, convolution algorithms rely on this property because they compute the image one pixel at a time and sum the destination into the final image.

The linearity property also means that if you convolve an image with one kernel and then convolve it with another, the destination is the same as convolving the image with a kernel whose elements are the sums of the corresponding elements of the other two kernels:

Was this article helpful?

Through this ebook, you are going to learn what you will need to know all about the telescopes that can provide a fun and rewarding hobby for you and your family!

## Post a comment