Weird behaviour of `Volume(img)`
See original GitHub issueUsing Volume
to render data from a numpy array seems to mess up the axes order (see screenshot below). At the same time building a vtkImageData
manually works fine.
I’m getting this behaviour only after reinstalling my python environment and updating vtkplotter
. Unfortunately I can’t find the configuration in which things would work as they did before, so here’s code illustrating the problem:
import vtk
import numpy as np
from vtkplotter import show, embedWindow, Volume
embedWindow('itkwidgets') # backends are: itkwidgets, k3d or False
import skimage.io as io
f = 'embryo.tif' # from the vtkplotter examples
raw = io.imread(f, plugin='simpleitk')
arr = vtk.util.numpy_support.numpy_to_vtk(raw.transpose(2,1,0).ravel(), array_type=vtk.VTK_FLOAT)
img = vtk.vtkImageData()
img.SetDimensions(raw.shape)
img.GetPointData().SetScalars(arr)
# doesn't work
# show(Volume(raw.transpose(2,1,0)))
show(Volume(raw))
# show(Volume(raw)._image)
# show(Volume(raw.transpose(2,1,0))._image)
# works
# show(img)
This is the output:
Thanks! Cheers, Marvin
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Weird behaviour of `Volume(img)` · Issue #78 · marcomusy/vedo ...
Using Volume to render data from a numpy array seems to mess up the axes order (see screenshot below). ... Weird behaviour of...
Read more >Volume with negative spacing turns in strange behaviour (bug?)
When I try to add volume with negative spacing in X direction to Slicer I get strange behavior. Then I go to the...
Read more >Strange behaviour on Office 2019 Volume Licensed on a ...
We are experiencing this strange behaviour: opening an Office application (Excel, Word, etc) and closing it, the relative process is released ...
Read more >Weird behaviour of "Allow Over-Amplification" Switch in Sound ...
Issue: The Over Amplification Key has slightly weird behavior. If the switch is on, and volume is set to > 100%, and the...
Read more >Weird behaviour when snipping content from the audio track ...
Weird behaviour when snipping content from the audio track ... the remaining parts, the audio volume immediately prior to the snip greatly decreases....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works for me as well. Thanks so much for looking into this so quickly and fixing! Cheers, Marvin
Actually I said something completely wrong… the
trasnpose
thing doesn’t fix the spacing order… so in the end I believe the order=‘F’ would simplify the operation, so the above becomes:I committed the new version… sorry for the confusion and thanks a lot for the help! Let me know if this does the job… M.