Consider two images which have been calibrated by attaching FrameSets to them, such that the base FrameFrame of each FrameSetFrameSet corresponds to the raw data grid coordinates of each image (the GRID domain of §7.13). 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 astCopyastCopy—§4.13), 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. astInvertastInvert will perform this task:
To identify the required conversion, we now use astConvertastConvert, supplying a suitable domain search path with which we would like our two images to be registered:
The effects of this are:
The resulting “cvt” FrameSet may then be used directly (§12.1) 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 BaseBase attribute of each FrameSet is set by astConvert 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 DomainDomain value:
If conversion was successful, the result will be one of the strings “SKY”, “PIXEL” or “GRID”.