After upgrading from vtk.js 33.x to 34.0.0, color (RGB) images are no longer rendering in our stack viewport (source code) , while grayscale images continue to work fine. I’ve reviewed the diff between versions 33 and 34 and checked the changelog, but I cannot locate what has changed regarding the image mapper that would cause this issue.
I noticed a lot of changes to volume mappers in version 34.0.0, but I couldn’t find any significant updates to image mappers when checking the diffs.
After Upgrade to vtk.js 34.0.0
- i can confirm the number of components is set to 3
- I can confirm independent components is set to false
- i can confirm it works fine in gray scale
- i can confirm the pixel data is correctly formatted
In vtk.js 33.xx
this looks like to me like different channels are not being treated correctly somehow and are concatenated?
In summary here is how we do it in Cornerstone3D with image mapper:
Creating vtkImageData with RGB Data
// Creates vtkImageData with 3-component RGB data
function createVTKImageData({ origin, direction, dimensions, spacing, numberOfComponents, pixelArray }) {
const scalarArray = vtkDataArray.newInstance({
name: 'Pixels',
numberOfComponents: numberOfComponents, // 3 for RGB
values: pixelArray, // Assuming pixelArray contains the values
});
const imageData = vtkImageData.newInstance();
imageData.setDimensions(dimensions);
imageData.setSpacing(spacing);
imageData.setDirection(direction);
imageData.setOrigin(origin);
imageData.getPointData().setScalars(scalarArray);
return imageData;
}
Creating Image Mapper and Actor
function createActorMapper(imageData) {
const mapper = vtkImageMapper.newInstance();
mapper.setInputData(imageData);
const actor = vtkImageSlice.newInstance();
actor.setMapper(mapper);
// Set independentComponents to false for RGB images
if (imageData.getPointData().getScalars().getNumberOfComponents() > 1) {
actor.getProperty().setIndependentComponents(false);
}
return actor;
}
Any guidance on what might have changed or what additional configuration is needed would be greatly appreciated!
The PR we are working on the upgrade from 32 → 34 is feat: upgrade to vtk.js 34.x by daker · Pull Request #2398 · cornerstonejs/cornerstone3D · GitHub
checkout the PR (branch)
yarn install
yarn run example ultrasoundColors