next up previous
Next: Maintaining the Integrity of FrameSets
Up: Higher Level Operations on FrameSets
Previous: Re-Defining a FrameSet Coordinate System

Example--Binning an Image  

As an example of using astRemapFrame, 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 FrameSet 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 Mapping (a WinMap in this case) which relates the data grid coordinates in the original image to those in the new one:

AstWinMap *winmap;
double ina[ 2 ] = { 0.5, 0.5 };
double inb[ 2 ] = { 2.5, 2.5 };
double outa[ 2 ] = { 0.5, 0.5 };
double outb[ 2 ] = { 1.5, 1.5 };

...

winmap = astWinMap( 2, ina, inb, outa, outb, "" );

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''). astWinMap 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 Frame 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:

AstFrameSet *frameset;

...

astRemapFrame( frameset, AST__BASE, winmap );

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.



next up previous
Next: Maintaining the Integrity of FrameSets
Up: Higher Level Operations on FrameSets
Previous: Re-Defining a FrameSet Coordinate System

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
30th April 2003
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2003 Central Laboratory of the Research Councils