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
579 stars 83 forks source link

Blend two images using itkwidgets #613

Closed gourav3017 closed 1 year ago

gourav3017 commented 1 year ago

How can I blend two itk images? I have CT in one image and dose distribution on the other image. I want to show CT in background with dose in foreground. Is it also possible to overlay structure contours/mask on these blended image using itkwidgets? image

PaulHax commented 1 year ago

If you combine the 2 images into 1 image with 2 components with itk, itkwidgets will display a mix of the 2 components, not so much an overlay:

https://kitware.github.io/itk-vtk-viewer/app/?image=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr&use2D=true

thewtex commented 1 year ago

@PaulHax let's add the compare function to meet @gourav3017 's needs.

gourav3017 commented 1 year ago

Thanks @PaulHax @thewtex . But if I combine two itk images and view them using itkwidgets using the above link, I cannot have a different color map for the background image and foreground image. For my example, I want to have a grayscale for ct scan and a jet/rainbow for dose distribution

PaulHax commented 1 year ago

The link is an example of the image result you can currently ac heave with itkwidgets. Click the numbered tabs and the purple bar to change the color map of the components: Screenshot from 2023-02-13 17-45-28

gourav3017 commented 1 year ago

@PaulHax If I try to combine two itk images into one with two components using compose filter, I get an error with viewer "RuntimeError: Could not process the viewer data" since my itk image pixel type is vector now. Can you share the code for the above example where you can combine two itk images into one with two components? Sry. I am more not into C++. It would be great if you can share the code for combining images using python itk

PaulHax commented 1 year ago

itkwidgets can view vector images. I don't know where that error is coming from.

What version of itkwidgets are you using. Try pip install 'itkwidgets[all]>=1.0a16'.

If that does not work, would you mind sharing a notebook showing the problem?

gourav3017 commented 1 year ago

Following is the screenshot where viewer throws when I tried using combined image using compose image filter and get vector image. Error_itkwidgets

gourav3017 commented 1 year ago

I checked my itkwidgets version and it was installed using above command "pip install 'itkwidgets[all]>=1.0a16'". My current version is 1.0a23

PaulHax commented 1 year ago

I am getting that error too with the attached notebook. itkwidgets does not like the itk.itkVectorImagePython.itkVectorImageSS3 type somehow. Hello3DWorld.zip

gourav3017 commented 1 year ago

ohh okay. Do you think if there is any workaround to combine the images and display it using itkwidgets? Below is the notebook example I created for combining ct and dose and it throws error using itkwidgets. You can clone the repo and run the example Share.ipynb. https://github.com/gourav3017/data.git

PaulHax commented 1 year ago

I'm baffled.

@bnmajor Anything we should try?

bnmajor commented 1 year ago

@PaulHax I was just looking into this and don't currently have an answer.... To handle the data streaming we need to be able to convert the vector image to an ngff zarr but I am not sure how to go about that right now. Unless you have some ideas on how to convert I will come back to this tomorrow morning after I meet with Matt and pick his brain.

@gourav3017 Right now I don't have a workaround but as soon as we have one (or a solution merged in) I will let you know!

bnmajor commented 1 year ago

@gourav3017 - I spoke with @thewtex this morning and I have opened an issue to add support for itkVectorImage (see thewtex/ngff-zarr#10) so that we can handle these images in itkwidgets.

@PaulHax

gourav3017 commented 1 year ago

Thank you very much @bnmajor @PaulHax

thewtex commented 1 year ago

itk.itkVectorImagePython.itkVectorImageSS3 type somehow. Hello3DWorld.zip

This now works with #638

image

bnmajor commented 1 year ago

Awesome, thanks @thewtex!

@gourav3017 Thanks for bringing this to our attention! If you have any other problems please feel free to open another issue.