Change interpolation method

Hi everyone,

Is there a way to interactively change the interpolation method of a volume node. I have tried the following withtout success.

volumeNode=getNode(“my_volume_name”)
volumeNode.GetDisplayNode().SetInterpolation(2)

But nothing changed. So I then tried.

volumeNode.GetDisplayNode().UpdateImageDataPipeline()
volumeNode.GetDisplayNode().Modifed()

Nothing changed.

Thanks for your help,
Pierre

It appears you are trying to use PhongInterpolation for more realistic shading?

Have you tried the “Lights” module for various interactive lighting techniques for shading?

I was probably misled by the name, sorry this is not what I wanted to do. I would like to change the interpolation in the MPR views of a particular volumeNode

it seems that interpolation is hard-coded to linear if interpolate is on or nearest neighbor if interpolate is off

Volume interpolation in slice views is controlled by the Interpolate flag. However, the flag is already enabled by default, so I would not recommend touching it. If you disable it then you introduce artifacts in the image reconstruction. See more details here.

If you just want to show boundaries of voxels then don’t use nearest neighbor interpolation, because it would ruin the image by aliasing artifacts and by the increased image contrast that is needed to make the random noise between neighbor voxels large enough so that your eye can make out individual voxels. Instead you can use this small Python code snippet to show the voxel grid in slice views.

If you want to have higher-order interpolation then you can enable it like this for a specific view (it is not exposed on the GUI, as the feature remained in an experimental stage; see some more information here):

sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
slicer.app.applicationLogic().GetSliceLogic(sliceNode).GetBackgroundLayer().SetInterpolationMode(vtk.VTK_RESLICE_CUBIC)
slicer.util.forceRenderAllViews()

Exactly what I was looking for thanks Andras !
Pierre

Which solution did you choose?

the last one, but for now I do not see any change between linear and cubic

Sorry, I should have zoomed more to see differences. So this is working.

1 Like

Great!

Probably it would not have any downsides to add an application setting to choose between linear and cubic interpolation. If you find that cubic interpolation works better and you don’t want to maintain a custom solution then it would be great if you could submit a pull request that adds this option (a combobox in application settings that sets an InterpolationType enum in vtkMRMLSliceNode and vtkMRMLSliceLayerLogic uses that value to set interpolation type in the reslice filter). Probably cubic could be the default but the user could change it in the application settings to linear.

1 Like