How to set voxel value based on absolute distances/coordinates from origin in simpleITK

193 Views Asked by At

I have a dicom 3D image and additional file describing binary mask. Binary mask is encoded with XYZ coordinates:

5.123422, 6.123123, 5.123123; 5.123422, 6.123123, 5.123123; 5.123422, 6.123123, 5.123123 ...

I want to transform those encoded points into dicom (or other 3d format I can convert). Since dicom structure has fixed dimensions between its voxels and this structure is known. I am guessing that I can just read coordinates from file and set values of the points based on proximity. Are there better solutions?

1

There are 1 best solutions below

0
On BEST ANSWER

This seems like a job for TransformPhysicalPointToIndex in a for loop:

for (auto p in points)
{
  auto index = maskImage->TransformPhysicalPointToIndex(p);
  maskImage->SetPixel(index, 255); // desired label
}

I don't think there are better solutions (based on my understanding of your problem).