itk-vtk-viewer icon indicating copy to clipboard operation
itk-vtk-viewer copied to clipboard

Make image region invalid and refresh the display

Open oeway opened this issue 3 years ago • 2 comments

Hi, would be nice if we can have an api function that allows us to make the entire image or a region invalid to force the viewer to pull data chunks, e.g. using the ImJoy API from the python process. This will be very useful to visualize the chunk-by-chunk processing progress. For example, when we do segmentation on large image in zarr format, we can use the viewer to display the raw input image and the result image. Before the segmentation, we can display the raw and an empty result image with a zarr store, as the segmentation goes, we can tell the viewer to update the processed patch one by one, so the user can see the result progressively.

This will be also useful when we do manual annotation combined with Kaibu (https://kaibu.org), when the user draw something on the canvas with the vector layer, we want to rasterise the stokes as an image stored on the server, then notify the viewer to render the updated region on a image layer, after that we remove the vector from the vector layer.

I guess we can already to this by calling setImage right? but is there any overhead for doing this? E.g. when we know there is only a small region has been updated, won't it be better to tell the viewer to update that part?

oeway avatar Jul 26 '22 23:07 oeway

Cool idea. Right setImage would start the loading of the whole image, again. Quick hack: expose the ImageData array at user API level and manipulate away there?

PaulHax avatar Jul 27 '22 15:07 PaulHax

Good thoughts!

I am thinking that we:

  1. Have a getContentIdentifier (hash), etc. associated with the MultiscaleSpatialImage for chunks.
  2. Have an InMemoryImage that sits between the input image as the in-memory cached content for rendering.
  3. When setImage is called, the InMemoryImage will go through its chunks (assuming the image size, etc. has not changed and it needs the same chunks) and updates the chunks that have the content identifier changed.

For Kaibu / manual segmentation / editing, we have a MultiscaleSpatialImage with special functionality to apply the vector layer inputs on demand and propagate the manual results across scales?

thewtex avatar Jul 27 '22 15:07 thewtex