Display problem with ColorTransferFunction

Hi, when I try the PaintWidge Example, I want to add more than one point of vtkColorTransferFunction which means label “1” will be gray and label “2” will be red for example.

labelMap.cfun.addRGBPoint(1, 1, 1, 1); // label "1" will be gray
labelMap.cfun.addRGBPoint(2, 1, 0, 0); // label "2" will be red

But when I set the label to “2” and paint some region, I found the drawn image borders are displayed in gray. Can anyone answer my confusion? Any suggestions will be helpful.

Here are some more obvious examples

Don’t you need to set a 255 to 0 value to your transfer function?

Hope it helps

Thanks for your reply. In Figure 1, I set “1” value to “1, 1, 1”(gray) and set “2” value to “1, 0, 0”(red). When I set the paint label to 1, paint operations can be displayed normally, but when I set the label to 2, the red region has a very thin gray borders. Is it a problem with my settings?

Maybe the values are float and go from 0 to 1

This doesn’t seem to work, the edges of the drawing area still have bugs displayed.

Try this method https://vtk.org/doc/nightly/html/classvtkProperty.html#a961853dcf5b86b4d6330076cc1f0af9e

Thank you

Which version of vtk.js are you using? If you are using a version >= v23.0.0, you will need to do the following:


Hi, Forrest. I updated the dependencies(now 24.18.7) and added this statement, but the problem still exists. As show in the picture, I just added the following code according to PaintWidget Example

labelMap.cfun.addRGBPoint(1, 1, 0, 0); // label "1" will be red
labelMap.cfun.addRGBPoint(2, 0, 1, 0); // label "2" will be green
labelMap.cfun.addRGBPoint(3, 0, 0, 1); // label "3" will be blue

I think the problem is on the edge properties not on the colormapping table

I’ll throw out a few things to try:

  • actor.getProperty().setInterpolationType(InterpolationType.NEAREST);
  • setting the opacity function such that label 4 (or 3.001) is 0.
1 Like

It worked by setting the InterpolationType, thank you!