My Octopress Blog

A blogging framework for hackers.

VTK and Volume Visualization

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:

1
head VTKData/ironProt.vk

This header more or less included a little information on the grid size, spacing and representation of the data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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: <div class=’bogus-wrapper’>

<figcaption></figcaption><div class=”highlight”><table><tr><td class=”gutter”><pre class=”line-numbers”>1 </pre></td><td class=’code’><pre>bash $> cat header CT-Head.raw > CT-Head.vtk </pre></td></tr></table></div>
</div>

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.

[gallery link=”file” orderby=”ID”]

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):