extract the coordinates of the point on the slice?

Hi, about the VTK.js, I want to ask you about how can I extract the coordinates of the point on the slice?

I successfully extracted the coordinates from a .stl file with the cellPicker/pointPicker, but no matter how I tried, I didn’t succeed in extracting the coordinates of the point on the slice.

Can anyone please help me? thanks a lot.

Can you provide more details about what you are slicing?

  • If you are slicing geometry and you get a boundary rather than a surface, then using the pickers won’t have anything to intersect with other than on the boundary.
  • If you are slicing an image, then point picker will give you world coordinates. You then need to transform that into image space via imageData.worldToIndex(coords).

I think It is slicing an image.

I use imageMapper to get the imageData, then add the imageSlice to the renderer as follow.

const imageMapper = vtkImageMapper.newInstance();
const imageSlice = vtkImageSlice.newInstance();

imageSlice.setMapper(imageMapper);
imageMapper.setInputData(imageData);
renderer.addActor(imageSlice);

(The imageData is obtained by using the readImageDICOMFileSeries method of ITK and change them to vtkImageData)

Luckily I get the point through adding this

imageSlice.getMapper().setKSlice(0);

But I am still confused whether the result is correct and why we need that code.

In addition, during the attempt, I find another question. If I set the setKSlice(30) or other index, the result displayed is different when I import the .dicom files from 0 to 128 with the .dicom files from 0 to 80.

First, the image mapper has two important properties: slice index, and slicing mode. The slice index is which slice you want, and the slicing mode indicates which axis along which to slice. So slicing along the K axis with a slice index of 30 will give you the 30th slice in the K direction. It’s always a good idea to call mapper.setSlicingMode() (like in this example) and then mapper.setSlice(sliceIndex) so that you get the desired slice.

When using readImageDICOMFileSeries, you will get different bounding boxes depending on how many slices you read. For example, if you read slices 0-128, the resulting vtkImageData will have a larger bounding box than if you only read slices 0-80.

1 Like

I understand. In other words, we must set the slicingMode. Otherwise, even if the computer displays an image, we can’t get the point with the pointPicker.

By the way, about the difference, turns out I got the wrong direction which means that setKSlice(30) shows the 98th dicom file when I read slices 0-128.

Thanks a lot for the replications.