|
Volume Render From Bitmap Files |
|
|
|
|
Written by Mark Wyszomierski
|
|
Wednesday, 29 August 2007 |
Download article attachment: DevSample_RenderVolume_Bitmap.zip(18.0kb)
This sample shows how to create a volume rendering from a directory of bitmap files. It's uses the same WrapperVtkRenderVolume framework as in the Volume Render DICOM Dataset
article.
To load the bitmap files from disk, I originally attempted to use vtkBMPReader, but after fighting with it for awhile I gave up and wrote my own wrapper. vtkBMPReader has a seemingly strange interface for reading multiple files in a directory. The wrapper class I came up with, WrapperLoadVolumeFromBitmaps, has what I hope is a much simpler interface. All that's required is a path to a directory and it will load every valid bitmap file in the directory into a vtkImageData instance (what we're trying to volume render).
Keep in mind that bitmap files have no ordering information in them (unlike DICOM files), so your bitmap files should be named in such a way that when sorted as strings, end up in the right order. As an example, I would name my files like:
- C:\test\slice_00.bmp
- C:\test\slice_01.bmp
- C:\test\slice_02.bmp
- etc..
The WrapperLoadVolumeFromBitmaps class will sort all these paths internally as text to get the final slice order.
Bitmap files also have no information as to slice spacing or pixel spacing, so I put a default set of values as 1, 1, and 3 for the (x,y,z) spacing components. This should be changed to reflect the actual values in your case, or the final volume may come out looking warped.
The vtkVolumeTextureMapper3D class is used to perform the actual volume rendering. It wants 4 component data, the 4th component being an alpha channel. The WrapperLoadVolumeFromBitmaps class will create a simple alpha channel for the input bitmaps by averaging the values of the first three components (this happens per pixel). You should define your own alpha components to suit your dataset.
In future versions of VTK, I hope the image reading classes all support one generic interface for setting a list of files to read. This way it would be very simple to create a generic volume reader for bitmaps, DICOM files, tifs, etc. At this time I am using release version 5.0.3.
If you have any questions or comments, please post them. This project was created under visual studio 2005. |