I’m trying to color a surface generated from vtkImageData using the values from another vtkImageData. This is the code to generate the surface:
surface = vtk.vtkMarchingCubes() surface.SetInputData(imgstenc.GetOutput()) surface.ComputeNormalsOn() surface.SetValue(0, 127.5)
Where “imgstenc” is an vtkImageStencil object that generates a binary image from a bone surface mesh. Then I process the binary image to compute the thickness of the bone. Results are in another vtkImageData variable called “thickness” with the same dimensions, origin and spacing than “imgstenc”.
I’m trying to color each cell from the surface object using the values from the “thickness” vtkImageData to obtain something like this:
Where warmer colors mean larger values of thickness. I’ve been trying to assign the thickness value to each surface cell with something like this:
color = vtk.vtkUnsignedCharArray() color.SetNumberOfComponents(1) color.SetNumberOfTuples( surface.GetOutput().GetNumberOfCells() ) for i in range(surface.GetOutput().GetNumberOfCells()): color.InsertTuple(i, <????>)
But I don’t know how to extract the corresponding thickness value to each surface cell. Any idea??
Thanks a lot!