How to turn off interpolation for discrete label segmentation image?

Thanks for the reply!

Just want to confirm that the Nearest Neighbor Interpolation is not taking average of the neighboring voxels, right? I’m asking because now I suspect the issue might be caused by the incorrect interpolation in the downsampling from the upstream data pipeline (not vtk-js related).

Here’s my lut configuration. The original segmentation should only have label 4. But now 1, 2, 3, are also showing up at the border.

image

const seg_lut = vtkColorTransferFunction.newInstance();
seg_lut.setIndexedLookup(true);
seg_lut.setMappingRange(0, 4);
seg_lut.addRGBPoint(0, 0, 0, 0);
seg_lut.addRGBPoint(1, 1, 0, 0);
seg_lut.addRGBPoint(2, 0, 1, 0);
seg_lut.addRGBPoint(3, 0, 0, 1);
seg_lut.addRGBPoint(4, 1, 0.87, 0.74);

seg_actor.getProperty().setRGBTransferFunction(0, seg_lut);
seg_actor.getProperty().setColorLevel(2);
seg_actor.getProperty().setColorWindow(4);

const ofun = vtkPiecewiseFunction.newInstance();
ofun.addPoint(0, 0);
ofun.addPoint(1, 0.8);

seg_actor.getProperty().setScalarOpacity(ofun);
seg_actor.getProperty().setInterpolationTypeToNearest();