[vtkusers] Overlaying a slice on top of a vtk volume

David Gobbi david.gobbi at gmail.com
Mon Feb 8 17:45:57 EST 2010


Hi Anja,

Yes, you can rescale your MR slice to [0,255] and then you will not
have to use vtkImageMapToColors.  However, you will still need to
convert your slice to "unsigned char" with vtkImageCast or
(equivalently) rescale and cast it in one step using
vtkImageShiftScale.

By default the image will appear inside the volume.  That is why I
suggested that you should add a clipping plane to your
vtkVolumeMapper, so that you can clip away the part of the volume.

If you really want the image to appear in front of the volume (though
I think that clipping the volume is a better way of doing things),
then you can move it by using vtkImageActor::SetPosition().

   David



On Mon, Feb 8, 2010 at 3:33 PM, Anja Ende <anja.ende at googlemail.com> wrote:
> Hi David,
>
> Thanks for the quick reply!
>
> So with this I can just create a vtkImageActor, set my volume as an
> input and then use the SetDisplayExtent to show the relevant slice.
> This actor, I guess just gets added to the renderer. Thanks for the
> top on adding the vtkPlane to the volume mapper. Just a couple of
> questions:
>
> - Is there something that I will have to to ensure that the volume is
> behind the image actor?
> - Also, I am not very experienced with using the vtkImageMapToColors.
> So, I have a grayscale MR slice and I would like to display it the way
> it is. I guess just scaling the values to [0, 255] would do the
> trick... Could you give me some further pointer on how I can go about
> doing this?
>
> Thanks again for your help.
>
> Anja
>
>
> On 8 February 2010 22:20, David Gobbi <david.gobbi at gmail.com> wrote:
>> As long as an orthogonal slice is okay (i.e. along the x, y, or z
>> direction), just use vtkImageActor and use the SetDisplayExtent method
>> of the image actor to set the slice that you want to display.
>> ImageActor expects RGB (or RGBA) data, so you will have to pass the
>> image through vtkImageMapToColors (with an appropriate vtkLookupTable)
>> before putting it into the image actor.
>>
>> You will probably also have to add a vtkPlane to the VolumeMapper as a
>> clipping plane, so that you can clip away the part of the volume that
>> would otherwise be in front of the image.  The clipping plane must be
>> set to coincide with the image slice shown on the image actor.
>>
>>  David
>>
>>
>> On Mon, Feb 8, 2010 at 2:56 PM, Anja Ende <anja.ende at googlemail.com> wrote:
>>> Hello everyone,
>>>
>>> I am going a simple volume rendering with vtkVolume and it seems to
>>> all work ok. One thing I want to do is overlay a slice on top of this
>>> rendered volume. For doing the volume rendering, I used David Gobbi's
>>> Medical4.cxx example and it works quite well.
>>>
>>> So, I want to create a small animation where I render the volume and
>>> render some particular slice (vtkImageData) on top of it. What would
>>> be the best way to go about doing this?
>>>
>>> Cheers,
>>>
>>> Anja
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>
>
>
> --
> Cheers,
>
> Anja
>



More information about the vtkusers mailing list