[Insight-users] Visualizing a binary itk-Image

Gavin Baker gavinb+xtk@cs.mu.OZ.AU
Wed, 12 Mar 2003 13:01:58 +1100


Hello Zein,

On Tue, Mar 11, 2003 at 06:32:27PM +0100, salah wrote:

> How can visualize a 3D binary image (generated by an
> itk-segmentation filter) in 3D, i.e., not as slices using the fltk
> viewer??  Can I do that directly with the binary image, i.e, without
> generating a mesh?  Can I do that visualization with vtk?

You can certainly do this with VTK - it is an excellent choice.  You
don't need to generate a mesh; VTK will do that for you with a contour
filter.

Given you already have a binary volume, you can simply pass this to
something like marching cubes in VTK.  All you need do is choose the
level of the iso-surface (for example, 255 if your binary image is
8-bit).

I was trying to do a very similar thing recently.  I based my code
heavily on the examples, and hacked on it to learn how ITK and VTK
interface.  I threw together a simple little example that you can have
a look at and use how you like.  You can grab it at:

  http://www.cs.mu.oz.au/~gavinb/research/tools.php

It uses the headsq dataset from VTK.  It loads a 16-bit volume, blurs
it in ITK, then passes it to VTK which creates an isosurface and
renders it in 3D.  You may need to change the pixel type for the input
image to match your data (eg: unsigned char for 8-bit data).  It
should be fairly easy to adapt.  I hope it is of some use.

  :: Gavin

-- 
Gavin Baker                                Computer Vision Lab (CVMIL)
http://www.cs.mu.oz.au/~gavinb                 University of Melbourne