Volume Rendering

Contents

Introduction

Recently, I have been working on a volume renderer (raycasting). The task is to display volume data such as that recorded by computer tomography methods on a 2D screen. The data is structured in a 3D grid and fills a cuboid, in which each voxel is associated with a data value.

Now this volume is projected into 2D, and in order for the observer to get a "feeling" for the data, it is crucial to provide means for rotating the volume at will. Rotating a three-dimensional volume with a (2D) mouse for example is not trivial to do in an intuitive way.

At the beginning, although my program works satisfactory, I was unhappy because in order to make the rotation and everything work as expected, I had to swap coordinate signs and transformation matrices in a trial-and-error fashion.

The following text describes the theory behind the coordinate transformations necessary for this task. In contrast to the first assumption that there are two coordinate systems - one for the volume and one for the camera - which are rotated to each other, I came to the conclusion that my program actually employs no less than six coordinate systems. Furthermore, these coordinate systems are not only rotated and translated to each other, but other important properties are their handedness (right-handed vs. left-handed), the direction of the axes (for example, the mathematical y-axis points up, whereas in screen coordinates, it usually points down) and their resolution (i.e. the necessary transformations include scaling).

How Many Coordinate Systems?

Axis Alignment

Finally, let me discuss the handedness/axis-direction issue: The only coordinate systems which are fixed are the ones at both ends.

The other coordinate systems can be aligned freely. First, I chose to let the X axis point right in all systems.

The volume alignment is already determined through an alignment vector used for the transformation between volume system and object system. I chose to let the unit vector default to a right-handed system, where Y points down and Z to the back, so that loading a stack of images results in the images being rendered in the same orientation as they appear in an image viewer, in front-to-back order.

Conclusion

I have implemented a function coordTransform(c, ss, ts) which transforms a coordinate vector c from eg. the source system ss to the target system ts.

Moreover, the function has an additional optional paramter which determines whether translations should be applied. This is because one does not only want to transform position coordinates, but also direction vectors. These can be transformed using the same scaling and rotation transformations, but leaving any translation out.

Note: If you're using homogenous coordinates, you can distinguish direction- from position-vectors by their last (augmented) coordinate. If you augment the original vector with 1 (as usual), the transformations will include the translating parts. However, if the last coordinate is zero/ignored, the first three dimensions will be transformed in the same way as without homogenous coordinates/translations.


Valid XHTML 1.0! Valid CSS!
This page was last modified: Thursday, February 23, 2006 hacker emblem