Example—Binning an Image

As an example of using astRemapFrameastRemapFrame, consider a case where the pixels of a 2-dimensional image have been binned 2$\times$2, 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:


\begin{terminalv}
AstWinMap *winmap;
double ina[ 2 ] = { 0.5, 0.5 };
double inb[...
...ar
...
\par
winmap = astWinMap( 2, ina, inb, outa, outb, '''' );
\end{terminalv}

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:


\begin{terminalv}
AstFrameSet *frameset;
\par
...
\par
astRemapFrame( frameset, AST__BASE, winmap );
\end{terminalv}

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.