[vtkusers] problem access to specific voxel
Hal Canary
hal at cs.unc.edu
Sun Jun 9 09:50:43 EDT 2013
On 06/07/2013 01:08 PM, Hossein Nazem wrote:
> How can i access to specific voxel in VTK?
>
> I have a volume from CT image. From the dicom header I have "image
> position patient", "slice thikness" and "pixel spacing". For example
> if "image position patient"=[-137.699; -310.699; -1222], how can I
> reach this point in VTK? (for example change the color of this point)
Is something like this what you are looking for?
vtkSmartPointer <vtkDICOMImageReader > * dicomImageReader =
vtkSmartPointer <vtkDICOMImageReader >::New();
dicomImageReader->SetDirectoryName( /*....*/ );
dicomImageReader->Update();
vtkImageData * imageData = dicomImageReader->GetOutput();
double xyz[3] = {-137.699; -310.699; -1222};
vtkIdType index = imageData->FindPoint(xyz[0], xyz[1], xyz[2]);
if (index == -1) {
//point outside of bounds
} else {
double value =
imageData->GetPointData()->GetScalars()->GetComponent(index,0);
// do something with value.
}
More information about the vtkusers
mailing list