Volume problems
See original GitHub issueHi Marco, sorry to be opening so many issues…
I was playing around with the Volume
class and found a couple small issues.
Threshold in range
There seems to be something weird with volume.threshold
, if I only pass vmin
or vmax
it works as expected, but if I pass both it just returns the full volume and which particular values I use doesn’t change anything (in fact I can even pass vmax > vmin
).
bug in volume.resample
File "/Users/federicoclaudi/Documents/Github/BrainRender/workspace.py", line 41, in <module>
vol.resample([.1, .1, .1])
File "/Users/federicoclaudi/miniconda3/envs/brainrender/lib/python3.7/site-packages/vtkplotter/volume.py", line 291, in resample
oldsp = self.GetSpacing()
AttributeError: 'Volume' object has no attribute 'GetSpacing'
setting volume transparency.
I have these volumes that are 0 in empty voxels and >0 where there’s something. The actual scalar value in non-empty voxels doesn’t matter, it’s just to label voxels belonging to different structures.
So when rendering the volume I wanted all the 0 voxels to have alpha=0
and all the non-zero voxels to have alpha=1
, but I couldn’t find an easy way to do that with the alpha
argument of Volume
. I ended up doing this which works fine:
otf = vol.GetProperty().GetScalarOpacity()
otf.RemoveAllPoints()
otf.AddPoint(vmin, 0) # set to transparent
otf.AddPoint(vmin+.1, alpha) # set to opaque
otf.AddPoint(data.max(), alpha)
but I thought perhaps you wanted to build this possibility into the Volume
class.
All the best, Fede
P.s.: The slicers in the latest release look awesome!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
In the latest push this should be possible check:
vtkplotter -ir interpolateVolume
line:
# vol.alpha([(0.3,0.3), (0.9,0.9)]) # alternative way, by specifying (xscalar, alpha)
yep I think that would work, awesome thanks!