Kitware / VolView

Kitware VolView: an all-in-one radiological viewer!
https://volview.kitware.com
Apache License 2.0
169 stars 55 forks source link

Image range and histogram computation: cache, defer and/or optimize #567

Open PaulHax opened 4 months ago

PaulHax commented 4 months ago

To speed time to first image render, we can improve the range and histrogram computation in useAutoRangeValues: https://github.com/Kitware/VolView/blob/main/src/composables/useWindowingConfigInitializer.ts#L31-L38

The image is not rendered until the autoRangeValues are computed. Can we defer the computation and do it in a web worker?

The above chunk of code takes ~570ms for the CT volume here: https://volview-dev.kitware.app/?urls=[https://data.kitware.com/api/v1/file/63f39e907b0dfcc98f669cc6/download/joe-slim-pet-ct.zip] Can we optimize/parallelize?

autoRangeValues is computed 3 times for the same image on the initial load. Probably not needed.

floryst commented 4 months ago

This is semi-related to streaming (i.e. computation on chunks and merging results) and making sure various pieces of the app (e.g. the transfer function widget) don't re-compute the range & histogram.

floryst commented 3 weeks ago

An implementation note: the linked PR merely shunts the computation to a webworker. It still computes the histogram once per view, which is still inefficient. This can probably be resolved via some store state that tracks requests for window/level histograms.