Hello, I’m trying to develop a website using Python and react.
However, there is a problem that image data is generated normally, but rendering is not possible.
When I tested it with the conesource on the vtk homepage, it was rendered normally.
This is my Code
const width = pixelData[0].length;
const height = pixelData.length;
const depth = 1; // 단일 CT 슬라이스
const values = new Int16Array(width * height * depth);
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
values[y * width + x] = pixelData[y][x]; // 1D 배열로 변환
}
}
const dataArray = vtkDataArray.newInstance({
numberOfComponents: 1,
values,
dataType: "Int16Array",
});
const imageData = vtkImageData.newInstance();
imageData.setDimensions([width, height, depth]);
imageData.setSpacing([rowSpacing, columnSpacing, 1.0]);
imageData.setOrigin([0, 0, 0]);
imageData.getPointData().setScalars(dataArray);
imageData.modified();
const imageMapper=vtkImageMapper.newInstance();
imageMapper.setInputData(dataArray);
imageMapper.setSlicingMode(2);
const imageActor=vtkImageSlice.newInstance();
imageActor.setMapper(imageMapper);
imageActor.getProperty().setInterpolationTypeToLinear();
const renderer=fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
renderer.addActor(volume);
renderWindow.render();
Pixel Data has been received by Pythons.
Is the imageData object itself a problem?