OHIF / react-vtkjs-viewport

VTK.js image viewport component in React
https://react-vtkjs-viewport.netlify.com/
MIT License
142 stars 81 forks source link

Support for 8-bit images #153

Open bje43 opened 2 years ago

bje43 commented 2 years ago

@swederik how difficult would it be to add support for 8-bit images? Any chance you could help point me in the right direction?

https://github.com/OHIF/react-vtkjs-viewport/blob/0a3cb7932cb06275c2eb1497dfb2ba590860454b/src/lib/getImageData.js#L47

swederik commented 2 years ago

So right now the shaders in VTK.js only support Float32 and UInt8. We are working on enabling the use of Int16 and UInt16 in this PR here: https://github.com/Kitware/vtk-js/pull/2058

That's the main reason why we put these errors. I don't think we actually checked if it would work or not. It's just that we know it's slow to convert formats.

It's possible that if you just remove this if check and just try to use an Int8 ImageData, VTK may convert it to a Float32 before putting it into the shader anyway, but I've never tried.

See here: https://github.com/Kitware/vtk-js/blob/b189b7fa3b7f1205bfae1079a54d0d52761f5047/Sources/Rendering/OpenGL/Texture/index.js#L850