[vtkusers] Color a contour from a Niftii image
Andras Lasso
lasso at queensu.ca
Wed Oct 10 00:18:41 EDT 2018
The code that you shared extracts an isosurface at intensity value of 300, which means that all the voxels at the surface have this same intensity value. No matter what lookup table you specify because all point scalars retrieved by probe filter will have the value of 300.
If I understand correctly, you would like to extract a colored model from a volume, without segmentation - similarly to how a volume rendered image would look like, just with surface models. The issue is that this is not possible - see detailed discussion here: https://discourse.slicer.org/t/save-volume-rendering-as-stl-file/524. If the goal is to 3D print volume rendering in then you can do it with special 3D printers as described here (not from surface meshes): https://discourse.slicer.org/t/printing-volume-renderings-in-plastic/3017.
Andras
-----Original Message-----
From: vtkusers <vtkusers-bounces at public.kitware.com> On Behalf Of Renzo
Sent: Tuesday, October 9, 2018 10:42 PM
To: vtkusers at vtk.org
Subject: [vtkusers] Color a contour from a Niftii image
Hello,
I am trying to generate a visualization of a contour of a Niftii file, but with colors interpolated from that same image, not a monochrome representation. The resulting image shows the color variation, but it does not use the colors I set in my lookup table. Do you know why this could be happening? I wonder if it is because of the interpolation affecting not only hue, but also saturation and value parameters.
My code is below.
NiftiReader = vtk.vtkNIFTIImageReader()
ren = vtk.vtkRenderer()
ren.SetBackground(0, 0, 0)
renWin = vtk.vtkRenderWindow()
renWin.SetSize(800, 600)
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
surface = vtk.vtkContourFilter()
surface.SetInputConnection(NiftiReader.GetOutputPort())
surface.SetValue(0,300)
#Colors
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.SetTableRange(400, 905)
lut.SetHueRange(0.0, 0.75)
lut.SetSaturationRange(1.0, 1.0)
lut.SetValueRange(1.0, 1.0)
lut.Build()
#Map to colors
mapToC = vtk.vtkImageMapToColors()
mapToC.PassAlphaToOutputOn()
mapToC.SetLookupTable(lut)
mapToC.SetInputConnection(NiftiReader.GetOutputPort())
#mapToC.SetOutputFormatToLuminance()
mapToC.Update()
#Probe
probe = vtk.vtkProbeFilter()
probe.SetInputConnection(surface.GetOutputPort())
probe.SetSourceConnection(mapToC.GetOutputPort())
probe.Update()
# Create a mapper and an actor for the extracted surface smapper = vtk.vtkPolyDataMapper()
smapper.SetInputConnection(probe.GetOutputPort())
#smapper.ScalarVisibilityOn()
#smapper.SetLookupTable(lut)
#smapper.SetScalarRange(400, 905)
#smapper.SetScalarModeToUseCellData()
actor = vtk.vtkActor()
actor.SetMapper(smapper)
ren.AddActor(actor)
iren.Initialize()
renWin.Render()
iren.Start()
--
Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvtk.1045678.n5.nabble.com%2FVTK-Users-f1224199.html&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992416000&sdata=XHh3%2FvLPCo5y6bSZ948mMzu6yUNiJ%2FxZ0ntIiHCDbr8%3D&reserved=0
_______________________________________________
Powered by https://na01.safelinks.protection.outlook.com/?url=www.kitware.com&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992426005&sdata=TijHqv3xny7MSOSeZXBJMUcvIyItQSONJoWGJVbyVhs%3D&reserved=0
Visit other Kitware open-source projects at https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992426005&sdata=VkQW%2Bykknxgt4ao745Xy%2FuKPFKVOXuM0vkv0tINWCUU%3D&reserved=0
Please keep messages on-topic and check the VTK FAQ at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.vtk.org%2FWiki%2FVTK_FAQ&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992426005&sdata=AjHN3HsAls4X8Ikc4OKCGh5QmO7HlBuImbNvg9eSbgk%3D&reserved=0
Search the list archives at: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3Dvtkusers&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992426005&sdata=cHYAz%2Bijk2wA5JDo9km1LkWCPJL1PDriU1QiiOQW1Iw%3D&reserved=0
Follow this link to subscribe/unsubscribe:
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic.kitware.com%2Fmailman%2Flistinfo%2Fvtkusers&data=02%7C01%7Classo%40queensu.ca%7Cf52a42c6a4f84bd2059908d62e59e613%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636747360992426005&sdata=7oCmT%2BYJZNkAx3VcW9yFBly3yfdx2Cw2QNaad6PE64s%3D&reserved=0
More information about the vtkusers
mailing list