Closed jiaomei222 closed 1 month ago
Thanks for your great jobs! I found this code to be very inefficient:
for i in range(image.GetNumberOfPoints()): image.GetPointData().GetScalars().SetTuple1(i, inval)
Maybe you can try the following code:
scalars = image.GetPointData().GetScalars() from vtkmodules.util.numpy_support import vtk_to_numpy scalar_array = vtk_to_numpy(scalars) scalar_array[:] = inval scalars.Modified()
Hi,
Thanks so much! Code has been updated with your suggestions. It's true that it was highly inefficient, your method is waaaaay faster. Thanks again!
Best, Vicent
Thanks for your great jobs! I found this code to be very inefficient:
for i in range(image.GetNumberOfPoints()): image.GetPointData().GetScalars().SetTuple1(i, inval)
Maybe you can try the following code: