##
Example—Binning an Image

As an example of using astRemapFrameastRemapFrame, consider a case where the pixels of a 2-dimensional image have been binned 222#222, so as to reduce the image size by a factor of two in each dimension. We must now modify the associated FrameSetFrameSet to reflect this change to the image. Much the same process would be needed for any other geometrical change the image might undergo.

We first set up a MappingMapping (a WinMapWinMap in this case) which relates the data grid coordinates in the original image to those in the new one:

219#219

Here, we have simply set up arrays containing the data grid coordinates of the bottom left and top right corners of the first element in the output image (“outa” and “outb”) and the corresponding coordinates in the input image (“ina” and “inb”). astWinMapastWinMap then creates a WinMap which performs the required transformation. We do not need to know the size of the image.

We can then pass this WinMap to astRemapFrame. This modifies the relationship between our FrameSet's base FrameFrame and the other Frames in the FrameSet, so that the base Frame represents the data grid coordinate system of the new image rather than the old one:

220#220

Any other coordinate systems described by the FrameSet, no matter how many of these there might be, are now correctly associated with the new image.