In my project, I have segmented the heart, which means that I have a mask. The mask means the pixel inside heart is one, while the pixel outside heart is zero.
Now, I want to display only this heart using vtkFixedPointVolumeRayCastMapper without other tissue.
How can I display only this heart with the mask information?
I find vtkClipVolume may be helpful for my requirement. But it accept vtkImplicitFunction rather than a mask.
How can I clip vtkImageData with the specified mask? Any suggestion is appreciated~~~
The vtkFixedPointVolumeRayCastMapper only works with vtkImageData, so vtkUnstructedGrid is not useful for this situation.
One simple way to apply a mask is by multiplying with vtkImageMathematics. This might require changing the mask data type to the image data type, with vtkImageCast.
Or, another way to apply a mask is vtkImageStencil:
imageToStencil = vtk.vtkImageToImageStencil()
imageToStencil.SetInputData(maskImage)
stencilFilter = vtk.vtkImageStencil()
stencilFilter.SetStencilConnection(imageToStencil.GetOutputPort())
stencilFilter.SetInputData(heartImage)
# set "background" to a value that will be transparent for volume rendering,
# for example 0 for MRI, or -1000 for CT
stencilFilter.SetBackgroundValue(0)
Hi Zhang,
I guess this question related to this topic created by you : How to crop 3D image from a 2D free-hand ROI? - #5 by Linfeng_Song . Have you manged to implement the free-form cut function ? I am implementing this function by just only using VTK code. Somehow it works with data with slicing (1, 1, 1), but for volume with different slicing the cut position is always not correct. Can you please help to share your algorithm of implementing free-form cut ? Thank in advance. BTW, is there any opportunity that I can know your contact and have a conversation about this topic.