To Astronomy Home Page
To Top Level Menu

Resampling Images

=================
CB211 Image by Roy Minnich
CB211  Image by Roy Minich Resampled to  have square pixels
The Resample function allows you change the number of rows and/or columns in your image. This is useful to permit larger images to be displayed on smaller video screens, to enlarge smaller images for better viewing, to match image sizes when you want to Align or Sum (functions which require both images to be the same size), or to get the right aspect ratio from non-square pixels. The image on the left is a CB211 image by Roy Minnich (used with permission) that shows the original aspect and the one on the right has been resampled to show the same number of rows and columns (the TC-211 chip is square). Both images were resampled to one half the original number of rows for this demo to save load time. The full size images show much more detail.

Resample Input Box
Resample Input Box

The use of the function is straight forward. It only works on the image in the A buffer and puts the result in the B buffer. When you select this function, you will be asked to put in the new values for the number of rows and columns. No entry in either field will retain the default (displayed) value.

Probably the most common use of this function will be to resample images from chips that have non-square pixels or to use the VGA 320x200 mode. A few calculations are needed.

Generally, you will want to increase the number of rows/columns in which your chip dimension is greatest (to end up with square pixels at the smaller dimension). For example, the TC-241 chip has 375 columns of 23 micron wide by 244 rows of 27 micron high pixels. If the image were changed to have 244*(27/23) = 286 rows, each image pixel would appear to be from a chip that has 23x23 micron pixels.

Simularly, the TC-245 chip has a mode with 252 columns of 25.5 micron wide by 242 rows of 19.75 micron high pixels. Here a change to 252*(25.5/19.75) = 325 columns would make each image pixel to appear to be from a chip that has 19.75x19.75 micron pixels.

To enlarge or reduce an image with square pixels simply apply the same ratio to each dimension (row and column). For example, suppose you wanted to display a squared TC-241 image of 375 columns by 286 rows to (more or less) fill a VESA 640x480 screen, you could use 286*(480/286) = 480 rows and 375*(480/286) = 629 columns.

VGA 320x200 mode pixels are not square so you would need a different calculation to be able to display your images with a correct aspect. Each VGA 320x200 mode vertical pixel height is 1.2 times greater than the horizontal pixel width. Thus, we would typically REDUCE the number of rows in our SQUARED image by a factor of 1.2.

For example, with the KAF-0400 chip which has 765x510 square pixels, we would decrease the number of rows to 510/1.2 = 425. Of course, a 765x425 image won't fit in 320x200 so we would have to reduce both diminsions by the same ratio to make it work (you could look at the top left 320x200 part of the image in correct aspect, though). To use the maximum amount of screen, we chose the ratio at 320/765 which will give us 320 columns by 178 rows (320/765*765= 320, 320/765*425 = 178).

For the TC-211 chip with 191x165 13.75x16 micron pixels, we would first increase the number of rows to 165*16/13.75 = 192 to get square pixels. To display these correctly on a VGA 320x200 screen, we would have to reduce the number of rows to 192/1.2 = 160. The resulting 192x160 could be increased by a 1.25 factor to get a 240x200 display that fits nicely into the 320x200 format and will display correct aspect.

Note that you don't have to go through all these steps at the computer. Once you decide the new number of rows and columns, simply input these at the correct prompt. For example, if you are using the TC-211 chip and a VGA video card, resample the original image to 240x200. If you are starting with a 765x510 KAF-0400 image, simply resample it to 320x178 and it will display correctly. Typically, you will be working with the same image source and computer, so all you have do is memorize (or write down) the correct rows and columns to use and you can use it all the time. This even applies if you bin your images (by the same ratio in rows and columns). Thus, if you are using a Kodak KAF-0400 chip and you have some images in the 2x2 or 3x3 binned modes, you would still use 320x178 images with a VGA 320x200 display. The Resample Table shows some typical settings you might want to try.

Finally for the more technically minded, the resampling algorithm conserves the flux and photometry is not affected. I.e., the stars will show the same magnitude after the resampling as before. The sky background or extended nebulosity will be different however (still conserving the flux).

To explain this with an example, the effect of resampling is to change the effective focal length of the imaging system (everything else remains the same). Suppose we have a system with 2.5 arcsec square pixels (imaging 6.25 sq arcsecs of sky each) and we wanted to resample to have 2.0 arcsec square pixels (imaging 4.0 sq arcsecs of sky each). For the same exposure time, sky brightness, etc., 4 sq arcsecs of sky is only going to produce 4/6.25 times as many photons/electrons per pixel as the original 6.25 sq arcsecs of sky did. Thus, the sky background (and all extended sources) will show up dimmer in the resampled image. This is the same result you would get with a telescope whose focal length is 2.5/2 = 1.25 times as long as the original.

If you calibrate a resampled image, your astrometry will still be highly accurate. In fact, JIMSAIP's calibration algorithm requires that the image pixels be square so, if you are working with a camera that produces non-square images in its native format, you must resample for astrometry. If you save a calibrated image, the calibration factors are saved with it. If you reload and resample such an image the calibration will not be valid so use caution.