[vtkusers] Drawing an image mask per slice on top of VtkImageViewer2 for a 3D data set

Delcypher delcypher at gmail.com
Fri Mar 2 10:45:31 EST 2012


Hi,
I have two 3D data sets

VtkStructuredPoints  named "original" of dimensions [512x512x120]
VtkStructuredPoints named "mask" of dimensions [512x512x120]

I'm currently using the VtkImageViewer2 class to view a slice at a
time of the image "original" and this seems to be working quite
nicely.

What I want is to have an image mask that is drawn on top of the
"original" image for each slice. I want the mask to come from "mask"
i.e. for every slice in "original" there is one corresponding mask for
that slice in "mask". When I switch slice using imageViewer I need a
way to make sure that the corresponding mask from "mask" is drawn on
the newly displayed slice.

I started looking at
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/Transparency which is
a good example but it is only for 2D images.

I took a look at the source code for VtkImageViewer2 and I think it
does the following...

1. Place the entire 3D image in the world co-ordinate system and place
the camera outside of this.
2. To select a particular slice VtkImageViewer2 seems to call
SetDisplayExtent(x_min , x_max, y_min, y_max,  NEWSLICE_NUMBER,
NEWSLICE_NUMBER) on its Actor so that only the relevant slice is
visible (assuming slices are arranged along the Z-axis). I presume
that these co-ordinates are local to the actor and are not world
co-ordinates, is that correct?

I'm quite happy to call SetDisplayExtent() myself on the VtkImageActor
for my "mask" image so that the right slice is used but what I'm
really unsure of is....
Where do I put the VtkImageActor for my "mask" image in the world
co-ordinate system so everything works (i.e. the mask's slices line up
perfectly for all slices)??

I consider placing the "mask" image Actor completely outside the block
of data for "original" but I have a strong suspicion this won't work
because VtkImageViewer2 adjusts the cliping planes of the Active
Camera of the renderer everytime the slice is changed so my "mask" may
be outside the clipping planes.

Or could I just place "mask" directly on top of "original" in the
world co-ordinate system?

Or better yet could I use a second VtkImageViewer2 for my "mask" image
and have both "VtkImageViewer2"s use the same renderer?

What's the best approach?

Regards,

Dan Liew.



More information about the vtkusers mailing list