Unexpected behaviour of Volume.legosurface()?
See original GitHub issueHello,
I’ve noticed a strange behaviour of Volume.legosurface()
method trying to visualize 3D binary matrix (boolean values representing object/background) and/or 3D label matrix (integer values representing different regions).
To illustrate this, consider the following example:
import numpy as np
data_matrix = np.zeros([10, 10, 10], dtype=np.uint8)
# all voxels have value zero except:
data_matrix[0:2, 0:2, 0:2] = 1
data_matrix[4:5, 4:5, 4:5] = 2
data_matrix[7:10, 7:10, 7:10] = 3
from vtkplotter import Volume, Plotter
vol = Volume(data_matrix)
EPS = 1e-6
msh = vol.legosurface(vmin=1-EPS, vmax=3+EPS, cmap=['red', 'green', 'blue'])
vp = Plotter(bg="black")
vp.add(msh)
vp.show(axes=1)
Issue no. 1:
I think that parameters vmin
and vmax
are not properly described in the documentation, i.e. the documentation states that
- vmin (float) – the lower threshold, voxels below this value are not shown.
- vmax (float) – the upper threshold, voxels above this value are not shown.
but it seems that parameters
vmin
andvmax
define a range (i.e. (vmin, vmax)) not the interval (i.e. [vmin, vmax]) – not a big deal (can be handled withEPS
or something similar) but can cause unexpected behaviour.
Issue no. 2:
My expectations of legosurface()
behaviour was that the code listed above will plot three cubes: 1x1x1 (red), 2x2x2 (green) and 3x3x3 (blue). In other words, I expected to see “voxelized” plot of these three regions. However, vtkplotter produced 0x0x0 (red), 1x1x1 (green) and 2x2x2 (blue) regions: https://prnt.sc/rmk0yo
Whether this is a bug or I didn’t understand the usage of this method well?
It is not a big problem for many use-cases, but I am trying to use vtkplotter to visualize image segmentation output in 3D, where each voxel counts. 😃
Thank you!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Thank you, this looks much more elegant compared to the trick with dummy orientation vectors scaled by scalar values.
Nice! I had a look at it yesterday and came up with a similar solution… I’ll see if can improve on the
Glyph
class to make it a bit more versatile…