I have a vtkVolume and I have to check all the voxels to keep the coordinates of the points with a certain value in some lists. For example, if the possible values are 3 (for example 0, 1, 2), I have to check all the voxels of the volume and keep in 3 different lists the coordinates of the points that have value 0, those that have value 1 and those that have value 2.
What are the most efficient ways to do this with numpy? I tried to iterate over the whole volume with shape (512, 512, 359) with some classic nested for loops but it takes too long.
numpycompiled methods can iterate efficiently, but you are limited to the provided methods. There are tools likenumbaandcythonfor writing your own compiled code. But for iteration in Python, lists, even nested lists, are better than arrays. You need to read some morenumpybasics.