## Resampling

When you take an image, the CCD samples the continuous pattern of light and dark at the focal plane of the telescope, breaking the image into discrete pixels. In resampling, you treat the discrete pixels as points on a continuous flow of light and interpolate a new set of samples; that is, you create a new image by taking new samplesâ€”or resamplingâ€”the old one.

You can resample to create an image with more pixels than the original by supersampling, or with fewer pixels by subsampling. While supersampling does not create new information, the interpolated pixels give the image a smooth, rounded appearance, eliminating the blocky "square stars" that many people find

Figure 12.9 Nobody likes images with that blocky "square stars" look. The cure is to resample the image so that interpolated pixels fill in and smooth boxy edges. In this example, a 60-pixel wide by 80-pixel high Horsehead clip has been resampled to 240-pixels wide by 320 pixels high.

objectionable. Subsampling results in the loss of some information, but can squeeze the image into a smaller screen space and smaller file.

The procedure below resamples the image array old ( ) into an image new ( ) that is newwidth pixels wide and newheight pixels high.

PROCEDURE RESAMPLE (newwidth, newheight) xratio = newwidth / (xmax + 1) yratio = newheight / (ymax + 1) FOR xp = 0 TO newwidth -1

FOR yp = 0 TO newheight - 1 x = xp / xratio y = yp / yratio xf = x - INT(x) yf = y - INT(y) a = old(INT(x), INT(y)) b = old(INT(x), INT(y)+1) c = old(INT(x)+1, INT(y)) d = old(INT(x)+1, INT(y)+1) new(xp,yp) = a * (1-xf) * (l-yf)_ + b * (1-xf) * yf_

NEXT yp

NEXT xp