InsightSoftwareConsortium / itkwidgets

An elegant Python interface for visualization on the web platform to interactively generate insights into multidimensional images, point sets, and geometry.
https://itkwidgets.readthedocs.io/
Apache License 2.0
585 stars 83 forks source link

Updating image of the widget is slow #114

Open hadim opened 5 years ago

hadim commented 5 years ago

I am trying to create a 3D-5D viewer to display 2D images with some sliders to navigate along other dimensions such as time, channel and z.

To update the image I just set the image attribute of the widget to the new image:

if not self.image_widget:
    self.image_widget = itkwidgets.view(self.current_image, ui_collapsed=False, annotations=True,
                                        interpolation=False, cmap='Viridis (matplotlib)', mode='v',
                                        shadow=True, slicing_planes=False, gradient_opacity=0.22)
else:
    self.image_widget.image = self.current_image

It works well but the image update is slow when moving the sliders. The same issue happens with a low-resolution image.

Here is a binder that reproduces the issue: https://mybinder.org/v2/gh/hadim/binder-sandbox/master?urlpath=lab/tree/notebooks/Image%20Viewer.ipynb

hadim commented 5 years ago

xref: https://github.com/jupyter-widgets/ipywidgets/issues/2081

thewtex commented 5 years ago

Here is a binder that reproduces the issue: https://mybinder.org/v2/gh/hadim/binder-sandbox/master?urlpath=lab/tree/notebooks/Image%20Viewer.ipynb

Very nice!

I am trying to create a 3D-5D viewer to display 2D images with some sliders to navigate along other dimensions such as time, channel and z.

To get the behavior you want, we will likely need true 4D support, discussed in #74. We will need to buffer enough data client side time-wise and transfer it into WebGL buffers for the transitions to be fast.

thewtex commented 4 years ago

In 0.27.2, data transmission rates are ~20x faster, so it may be practical without dedicated time support.