question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected behaviour of Volume.legosurface()?

See original GitHub issue

Hello,

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 and vmax define a range (i.e. (vmin, vmax)) not the interval (i.e. [vmin, vmax]) – not a big deal (can be handled with EPS 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kemo993commented, Apr 16, 2020

Thank you, this looks much more elegant compared to the trick with dummy orientation vectors scaled by scalar values.

1reaction
marcomusycommented, Mar 28, 2020

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

vedo/base.py at master · marcomusy/vedo - GitHub
A python module for scientific analysis of 3D data - vedo/base.py at master · marcomusy/vedo.
Read more >
Thermomechanical Behaviour of Two Heterogeneous ...
particular volume size is known and is sufficiently low. In mathematical form, homogenization refers to an operation (indicated by the symbol. () or ......
Read more >
A Study of Sound Generated by a Turbulent Wall Jet Flow ...
The far field acoustics generated by turbulent flow over rough surfaces has been experimentally investigated in an acoustically treated wall ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found