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

fix(independentComponents): Require explicit RGB or RGBA pixelType #371

Closed thewtex closed 3 years ago

thewtex commented 3 years ago

Do not make an implicit assumption so independentComponents can be enabled via pixelType.

oeway commented 3 years ago

When passing ndarray from the ImJoy interface, since there is no way to explicitly set the pixelType, maybe we should support additional options for the setImage function?

thewtex commented 3 years ago

When passing ndarray from the ImJoy interface, since there is no way to explicitly set the pixelType, maybe we should support additional options for the setImage function?

To prevent option creep/explosion on the viewer interface, can the object be converted, then the pixelType set?:

https://github.com/Kitware/itk-vtk-viewer/blob/94807c6385f1a4aec5d1e26d210292b56df13a62/src/utils.js#L11

oeway commented 3 years ago

Hi, I don't fully get, how would you do it?

thewtex commented 3 years ago

E.g.

itkImage = ndarrayToItkImage(ndarray)
itkImage.imageType.pixelType = 14
viewer.setImage(itkImage)
oeway commented 3 years ago

Aha, well, yes and no, for js plugins we can potentially do that, but it will be hard for Python plugins where we just want to call viewer.setImage(numpy_array). We may not want to always import itk module, or have the ndarray2ItkImage() function defined in the caller plugin.

Since we are supporting layers in the viewer, I guess allowing an extra config object will be useful anyway, for example setting the name, colormap, contrast for the image.

thewtex commented 3 years ago

Let's keep pushing forward Python plugins that provide the desired functionality.

Eventually in the config object, we will support an entire image configuration (data + complete config).

github-actions[bot] commented 3 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: