Hello everyone, please I want to be able to read and display .mhd , .zraw dataset using vtk.js, but I coudn’t.
I saw online that I can use vtkXMLImageDataReader but still does not work.
Someone to help me out please ?
below is my full code ,
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import vtkXMLImageDataReader from '@kitware/vtk.js/IO/XML/XMLImageDataReader';
// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
// ----------------------------------------------------------------------------
// Loading Mhd files
// ----------------------------------------------------------------------------
const mhdReader = vtkXMLImageDataReader.newInstance();
mhdReader.setUrl('dataset/combined_label.mhd', { binary: true});
mhdReader.loadData().then(() => {
const imageData = mhdReader.getOutputData();
// Create mapper and actors
const mapper = vtkMapper.newInstance();
mapper.setInputData(imageData);
const actor = vtkActor.newInstance();
actor.setMapper(mapper);
renderer.addActor(actor);
renderer.resetCamera();
renderWindow.render();
}).catch((error) => {
console.error('Error loading vtk file:', error);
Thank you for your help.