Navigation:  Image Viewer Architecture > The Scene Graph >

Spatial Transformations

Previous pageReturn to chapter overviewNext page

Every Graphic object has a SpatialTransform property which specifies the object’s affine transformation1 relative to its parent Graphic’s coordinate system.  This has the important implication that the cumulative transformation of a particular Graphic may be calculated by performing matrix multiplication on all the transformation matrices of its ancestors.

Let’s consider an example to make things a little clearer.  In the figure below, we’ve taken a few key nodes from the previous scene graph example.  Because the SceneGraph object has no parent, its cumulative transform is just its transform, which is just an identity transformation.  Moving one generation down, we see that CompositeImageGraphic has been scaled by a factor of 2.  Its cumulative transform is just the matrix product of its transform and the cumulative transform of its parent, which as we said, is an identity transformation.  Now, moving to the RoiGraphic, we see that its transformation matrix says that it should be translated 5 units in the +x direction and 3 units in the +y direction. But remember, that’s (5,3) in the coordinate system of its parent—CompositeImageGraphic—which itself has already been scaled by a factor of 2.  Thus, that (5,3) translation is actually a (10,6) translation in the coordinates of the SceneGraph.

This transformation model can be useful in many contexts.  Here are a few examples:

1.It is frequently desirable for vector graphics such as measurements to be “attached” to the image.  That is, when the image is zoomed or panned, its associated ROIs are zoomed and panned with it.
2.In the case of image stitching, you may want two images and their associated vector graphics to move independently of each other.
3.When panning a zoomed image, it can be useful to have a little navigation window in the corner indicating where you are in the context of the whole image.  That navigation window would have to have its own transformation parameters.

1  A thorough explanation of transform matrices is out of the scope this guide – there are a number of good resources online that can assist in this regard.  As a quick reference, however, recall that the general form of 2-dimensional affine transform matrices is as follows: