This week for Scientific Visualization, we’re talking about volume rendering and using VTK to explore some data. I got some datasets from The Volume Library and after a little tinkering, got VTK to render them. (And now a quick aside on how to do this as I didn’t find much information on the subject).
I used a tool (pvm2raw) available as part of the V^3 library to convert the pvm files to raw, but VTK requires its own simple header. I actually found that this particular header didn’t work (perhaps a VTK versioning problem?) and so taking guidance from this, checked the header of one of the VTK-included volumes:
bash $> head VTKData/ironProt.vk
This header more or less included a little information on the grid size, spacing and representation of the data:
# vtk DataFile Version 1.0
<Name of File>
BINARY
DATASET STRUCTURED_POINTS
DIMENSIONS <x> <y> <z>
ASPECT_RATIO 1 <y/x> <z/x>
ORIGIN 0 0 0
POINT_DATA <x * y * z>
SCALARS scalars <unsigned_char|unsigned_short>
LOOKUP_TABLE default
<remember to include a newline here>
Concatenating the header with the raw:
bash $> cat header CT-Head.raw > CT-Head.vtk
At that point, I was in business and was able to move on to generating pretty pictures. Granted, these datasets are pretty sparse, but still VTK did a pretty reasonable job. Update: a comment asked for a little bit more detail on this assignment, and so I’m including my report for the project.
- Bruce Gooch’s Head
- A CT-scan of a human chest
- The same chest, from a different direction
- An engine of some type
- A foot. ‘Nuff said.
- A delicious orange
I was amazed today that we can see inside of things… without taking them apart. What an age to live in. Especially the virtual autopsy table I read about recently. In 20 years, we’ll have Firefly-style real-time holographic body scans (ignore music, skip to 0:45):






Hey… been trying to get some pretty pictures following your comments, but cant get vtk to do any type of nice rendering… did you have to do any other sort of twicking to the datasets? I’ve downloaded them from the volume library, converted them to raw and added the header exactly as you post it… can you point out the points used for the transfer funcitions? perhaps show a bit of the code?
thanks alot
I’ve uploaded my report for the assignment, which has a little bit more detail about the transfer functions. The way I set it up, it reads the transfer function from a file (sure, it’s a little clunky) of the following format:
value1 opacity1
value2 opacity2
….
For example:
0 0.0
10 0.0
21 0.3
40 0.3
41 0.0
60 0.0
76 1.0
Here the transfer function is piecewise linear between these points. As I understand it, transfer function selection is still a largely open research problem. The biggest piece of advice that I can give is to insert single peaks into the data to explore where there are common values, and then mixing from there where appropriate.
There are also some widgets available (apparently), though I’ve not used them. This allows you to explore the function space a little more interactively.