resliceMapper.setLookupTable is not a function

Hey, how to set the Lookup Table for a resliceActor (vtkImageSlice)?
Because we can use setLookupTable method for a vtkMapper object but not for vtkImageMapper.
I need to set the LookupTable to make the black zone in the resliceActor transparent, is there a way to achieve this?

Thank you

You can use imageSlice.getProperty().setPiecewiseFunction(pwf) to translate voxel values into opacity levels. You can see an example here: vtk.js

1 Like

Thank you for your answer, I did what you told me, it is working fine!

  const ofun = vtkPiecewiseFunction.newInstance();
  ofun.addPoint(0, 1);
  ofun.addPoint(150, 1);
  ofun.addPoint(180, 0);
  ofun.addPoint(255, 0);

Edit update: the email contents don’t match up with the actual post contents, so ignore this post. I’ll leave it for posterity, but it answers a question that is no longer being asked.

What you’ve just defined is the following:

  • voxels with values 0-150 have opacity 1
  • voxels with values 150-180 have linearly decreasing opacity from 1 to 0
  • voxels with values 80-255 have opacity 0

If you want black (typically taken to be value 0), to be transparent, then set it to opacity 0.