[vtkusers] Transparency of a vtkImageActor in scene

David Gobbi david.gobbi at gmail.com
Wed Jan 18 12:13:05 EST 2012


Don't use vtkImageMapToWindowLevelColors.  This class does a few
things that I don't understand the purpose of, and one of those things
is that it forces the alpha value to 255, regardless of how alpha is
set in the lookup table.

If you use vtkImageMapToColors then the transparency should work as expected.

 - David


On Wed, Jan 18, 2012 at 5:00 AM, chasank <chasank at gmail.com> wrote:
> Hi all,
>
> I want to crop a volume and show the cropping planes with vtkImageActor. I
> use lookup table for visualization of my image data which its scalar data
> type is float. Alpha values of table values are linearly changing from 0 to
> 1 which meaning smaller scalar values are more transparent than the bigger
> scalar values. The problem is the area which has minimum scalar value is
> completely black in scene even it's alpha value is 0. Sample image data's
> scalar range is (0.0, 130.0). When I set every table value's alpha value to
> 0 volume of image data is completely disappears while the image actor stays
> same! Source code I use is below;
>
> lut = vtkLookupTable()
> lut.SetNumberOfTableValues(256)
> lut.SetTableRange(minIntensity, maxIntensity)
> lut.SetRampToLinear()
> lut.SetScaleToLinear()
> lut.Build()
>
> red, green, blue = constructLut('actc')
>
> for x in range(256):
>  lut.SetTableValue(x, float(red[x]/255.0), float(green[x]/255.0),
> float(blue[x]/255.0), float(x/255.0))
>
> level = 0.5 * (minIntensity + maxIntensity)
> window = maxIntensity - minIntensity
>
> imageMap = vtkImageMapToWindowLevelColors()
> imageMap.SetInputConnection(image.GetOutputPort())
> imageMap.SetOutputFormatToRGBA()
> imageMap.SetLookupTable(lut)
> imageMap.SetLevel(level)
> imageMap.SetWindow(window)
> imageMap.Update()
>
> ext = image.GetWholeExtent()
>
> actorMinX = vtkImageActor()
> actorMinX.SetInput(imageMap.GetOutput())
> actorMinX.SetDisplayExtent(ext[0], ext[0], ext[2], ext[3], ext[4], ext[5])
>
> renderer.AddViewProp(actorMinX)
>
> http://vtk.1045678.n5.nabble.com/file/n5154639/actor.png
>
>
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Transparency-of-a-vtkImageActor-in-scene-tp5154639p5154639.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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



More information about the vtkusers mailing list