next up previous 264
Next: Re-Defining a FrameSet Coordinate System
Up: Higher Level Operations on FrameSets
Previous: Converting between FrameSet Coordinate Systems


Example--Registering Two Images

Consider two images which have been calibrated by attaching FrameSets to them, such that the base Frame of each FrameSet corresponds to the raw data grid coordinates of each image (the GRID domain of [*]). Suppose, also, that these FrameSets contain an unknown number of other Frames, representing alternative world coordinate systems. What we wish to do is register these two images, such that we can transform from a position in the data grid of one into the corresponding position in the data grid of the other. This is a very practical example because images will typically be calibrated using FrameSets in precisely this way.

The first step will probably involve making a copy of both FrameSets (using AST_COPY--[*]), since we will be modifying them. Let ``frameseta'' and ``framesetb'' be pointers to these copies. Since we want to convert between the base Frames of these FrameSets (i.e. their data grid coordinates), the next step is to make these Frames current. This is simply done by inverting both FrameSets, which interchanges their base and current Frames. astInvert will perform this task:

      CALL AST_INVERT( FRAMESETA, STATUS )
      CALL AST_INVERT( FRAMESETB, STATUS )

To identify the required conversion, we now use AST_CONVERT, supplying a suitable domain search path with which we would like our two images to be registered:

      CVT = AST_CONVERT( FRAMESETA, FRAMESETB, 'SKY,PIXEL,GRID', STATUS )
      IF ( CVT .EQ. AST__NULL ) THEN
         <no conversion was possible>
      ELSE
         <conversion was possible>
      END IF

The effects of this are:

  1. AST_CONVERT first attempts to register the two images on the celestial sphere (i.e. using the SKY domain). To do this, it searches for a celestial coordinate system, although not necessarily the same one, attached to each image. If it finds a suitable pair of coordinate systems, it then registers the images by matching corresponding positions on the sky.

  2. If this fails, AST_CONVERT next tries to match positions in the PIXEL domain ([*]). If it succeeds, the two images will then be registered so that their corresponding pixel positions correspond. If the PIXEL domain is offset from the data grid (as typically happens in data reduction systems which implement a ``pixel origin''), then this will be correctly accounted for.

  3. If this also fails, the GRID domain is finally used. This will result in image registration by matching corresponding points in the data grids used by both images. This means they will be aligned so that the first element their data arrays correspond.

  4. If all of the above fail, AST_CONVERT will return the value AST__NULL. Otherwise a pointer to a FrameSet will be returned.

The resulting CVT FrameSet may then be used directly ([*]) to convert between positions in the data grid of the first image and corresponding positions in the data grid of the second image.

To determine which domain was used to achieve registration, we can use the fact that the Base attribute of each FrameSet is set by AST_CONVERT to indicate which intermediate Frames were used. We can therefore simply invert either FrameSet (to make its base Frame become the current one) and then enquire the Domain value:

      CHARACTER * ( 20 ) DOMAIN

      ...


      CALL AST_INVERT( FRAMESETA, STATUS )
      DOMAIN = AST_GETC( FRAMESETA, 'Domain', STATUS )

If conversion was successful, the result will be one of the strings ``SKY'', ``PIXEL'' or ``GRID''.


next up previous 264
Next: Re-Defining a FrameSet Coordinate System
Up: Higher Level Operations on FrameSets
Previous: Converting between FrameSet Coordinate Systems

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

Copyright (C) 2009 Science \& Technology Facilities Council