render new volume on same plot
See original GitHub issueHi all,
I would like to use vedo for volumetric rendering, but I would like to update the plot with a new volume render based off a slider value input. So, as the slider is moved, a new volume is rendered and displayed. Idea looks like this:
from vedo.pyplot import plot, histogram, show
from vedo import Volume, buildLUT, Plotter
import numpy as np
import nibabel as nib
import vtk
from vtk.util.numpy_support import vtk_to_numpy
import time
import vedo
import torch
# create slider
def slider1(widget, event):
# get slider value
value = widget.GetRepresentation().GetValue()
value = value/100
# linear interpolate between the two coords
z = z_0*value + z_1*(1-value)
# run interpolation
moved = decodeZ(z, moving, model)
# create the volume
vol = Volume(moved, c=bodyColors, mapper='fixed')
vol.mapper().SetClippingPlanes(planes)
# plot
plt.show(vol, interactive=False, camera=cam2, bg='black')
# initialize volume
vol = Volume(img, c=bodyColors, mapper='fixed')
vol.mapper().SetClippingPlanes(planes)
# add slider
plt.addSlider2D(slider1, 0, 100, value=0,
pos="bottom-right", title="Interpolate", c='blue')
plt.show(vol, interactive=True, camera=cam2, bg='black')
However, when the slider is moved, this gives the following error:
Traceback (most recent call last):
File "volMotion.py", line 138, in slider1
plt.show(vol, interactive=False, camera=cam2, bg='black')
File "/home/savjani/anaconda3/lib/python3.8/site-packages/vedo/plotter.py", line 2354, in show
self.allowInteraction()
File "/home/savjani/anaconda3/lib/python3.8/site-packages/vedo/plotter.py", line 778, in allowInteraction
self.interactor.DestroyTimer(self._repeatingtimer_id)
TypeError: DestroyTimer argument 1: an integer is required (got type NoneType)
There is likely a better way to update the plt with the new rendered volume, right? Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Volume rendering - 3D Slicer documentation - Read the Docs
Render different volumes in two views¶ · Go to Volume Rendering module · Open the “Inputs” section · Select the first volume ·...
Read more >Render two volumes simultaneously by blending them using ...
My goal is to blend two different scalar volumes of same size and spacing and display them using image plane widget. I have...
Read more >Visit-tutorial-Volume-Rendering - VisItusers.org
The Volume plot uses a visualization technique known as volume-rendering, which assigns color and opacity values to a range of data values.
Read more >3d volume plots in Python - Plotly
A volume plot with go.Volume shows several partially transparent isosurfaces for volume rendering. The API of go.Volume is close to the one of...
Read more >Volume rendering Feature - AtomicusChart©
Volume rendering is a set of data visualization techniques used for viewing and analyzing computer graphics and scientific data. Generally, volume rendering ......
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
From the next release you’ll be able to do simply:
@marcomusy - amazing, thank you so much! This is exactly what I was looking for.