Kitware / itk-vtk-viewer

2D / 3D web image, mesh, and point set viewer using itk-wasm and vtk.js
https://kitware.github.io/itk-vtk-viewer/
BSD 3-Clause "New" or "Revised" License
210 stars 64 forks source link

Load image bounded by camera frustum #563

Closed PaulHax closed 2 years ago

PaulHax commented 2 years ago

For the world bounds passed to MultiscaleSpatialImage.getImage(), updateRenderedImage() intersects the world axis aligned bounding box of the camera frustum with the cropping planes. Camera modified events trigger updateRenderedImage() after debounce.

Changes colorRange and colorRangeBounds to automatically grow after loading more image data. As image scales become finer, intensity extremes emerge. If the colorRange/colorRangeBounds are changed by the UI or API, they are "touched" and don't automatically change as new data is loaded. Before was calculating the range of data just once on the coarsest scale. However, that may have had a better result for visualization by clipping the extremes in the transfer functions.

PaulHax commented 2 years ago

We have camera modified debouncing, but do we have other criteria to only update the loaded by a "significant" change in the volume defined by the cropping planes?

The cropping planes trigger an image update after being debounced, same debouncer as camera modified, 500ms. Is that what you mean?

thewtex commented 2 years ago

The cropping planes trigger an image update after being debounced, same debouncer as camera modified, 500ms. Is that what you mean?

I think what we want is to only update the image content if the component chunks or scale would chancge, e.g. ideally this logic:

  1. cropping places or camera changes
  2. after debounce
  3. for the bounds, create a set of the indexes of the chunks that would be loaded and the required scale
  4. add a condition that a hash of the set has changed
  5. if the condition passes, go to the state for updating image state (still used that 'ing :-P)
PaulHax commented 2 years ago

I think what we want is to only update the image content if the component chunks or scale would chancge, e.g. ideally this logic:

  1. cropping places or camera changes
  2. after debounce
  3. for the bounds, create a set of the indexes of the chunks that would be loaded and the required scale
  4. add a condition that a hash of the set has changed
  5. if the condition passes, go to the state for updating image state (still used that 'ing :-P)

isImageUpdateNeeded condition does something similar. Hashes on image IJK indexes, hashing on chunks would have been better. https://github.com/Kitware/itk-vtk-viewer/blob/a5d40a08c95231c34943fa7d8d51cb8a979dfb79/src/Rendering/VTKJS/Images/imagesRenderingMachineOptions.js#L100-L104

https://github.com/Kitware/itk-vtk-viewer/blob/a5d40a08c95231c34943fa7d8d51cb8a979dfb79/src/Rendering/Images/createImageRenderingActor.js#L190

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 14.12.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: