[vtkusers] vtkImagePlaneWidget and vtkLookupTable being used partially?
Bruno Oliveira
nicoddemus at gmail.com
Wed Feb 1 14:09:49 EST 2017
Hi everyone,
Found the solution, posting here in case it helps others.
After some more digging a found that the problem was elsewhere in my
application code: *ambient light was set to zero*. That explains why the
texture on the vtkImagePlaneWidget was always black and changing colors in
the lookup table had no effect.
The solution is to disable lighting handling in the widget:
plane_widget.GetTexturePlaneProperty().LightingOff()
Cheers,
Bruno.
On Mon, Jan 30, 2017 at 4:44 PM Bruno Oliveira <nicoddemus at gmail.com> wrote:
> Hi everyone,
>
> I’ve looked at other emails from the mailing list but have not found
> anything which explains the problem I’m having.
>
> I have a vtkImageData object with scalars set as a vtkUnsignedCharArray
> ranging from 0 to 1. This volume represents rock porosity, with 0 meaning
> solid rock and 1 meaning a pore.
>
> I’m using 3 vtkImagePlaneWidget instances, each along one axis, to show 3
> plane cuts of the rock.
>
> I’m trying to use a vtkLookupTable to show solid rock as black, and pore
> as white:
>
> lookup_table = vtk.vtkLookupTable()
> lookup_table.SetNumberOfTableValues(2)
> lookup_table.SetTableValue(0, (0., 0., 0., 1.0))
> lookup_table.SetTableValue(1, (1., 1., 1., 1.0))
>
> Unfortunately the planes appear as completely black. Changing the color
> values to other colors (say, first entry red and second entry blue) has no
> effect on the image. If I change the first table entry’s alpha value to
> zero though, I can then see the pores of the image as black, which shows
> that the data is correct and that the lookup table is being used. It seems
> that it is not using the RGB part of the lookup table somehow.
>
> Here’s the relevant part of the code:
>
> self._plane_widgets = []
>
> lookup_table = vtk.vtkLookupTable()
> lookup_table.SetNumberOfTableValues(2)
> lookup_table.SetTableValue(0, (0., 0., 0., 1.0))
> lookup_table.SetTableValue(1, (1., 0., 1., 1.0))
> lookup_table.SetTableRange(0., 1.)
> for plane_name in ['XY', 'XZ', 'YZ']:
> orientation = vtk_reslice_details.GetVtkPlaneIndexValue(plane_name)
> slice_data = mpr_representation.slices_data[orientation]
>
> plane_widget = vtk.vtkImagePlaneWidget()
> plane_widget.SetInteractor(vizu.GetInteractor())
>
> plane_widget.GetPlaneProperty().SetColor(slice_data.norm_color)
> plane_widget.TextureInterpolateOff()
> plane_widget.TextureVisibilityOn()
> plane_widget.SetInputData(vtk_image)
> plane_widget.SetPlaneOrientation(orientation)
> plane_widget.SetSliceIndex(slice_data.slice_index)
> plane_widget.UserControlledLookupTableOn()
> plane_widget.SetLookupTable(lookup_table)
>
> plane_widget.SetMiddleButtonAction(vtk.vtkImagePlaneWidget.VTK_CURSOR_ACTION)
> plane_widget.SetRightButtonAction(vtk.vtkImagePlaneWidget.VTK_CURSOR_ACTION)
> plane_widget.On()
> plane_widget.InteractionOn()
> plane_widget.DisplayTextOn()
>
> self._plane_widgets.append(plane_widget)
>
> Any helps or tips are greatly appreciated.
>
> Cheers,
> Bruno.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170201/060107f1/attachment.html>
More information about the vtkusers
mailing list