[vtkusers] Read Particular pixel value
Kannan U V
kannanuv at cshl.edu
Tue Nov 5 14:18:49 EST 2013
Hi,
I am trying to find the value of a label at particular point in the image.
The pickedPoint gives me the x,y,z co-ordinate where I should pick the
value. How do I find the image value at that voxel? Since it is a label
image I want to use nearest neighbor interpolation. Can anyone give me
pointers of how to get the label value?
vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::SafeDownCast(obj);
iren->SetPicker(picker);
// get event position
int event_pos[2];
iren->GetEventPosition(event_pos);
// update label
QString str;
iren->GetPicker()->Pick(iren->GetEventPosition()[0],
iren->GetEventPosition()[1], 0,
iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double pickedPoint[3];
iren->GetPicker()->GetPickPosition(pickedPoint);
vtkSmartPointer<vtkImageCast> imageCast =
vtkSmartPointer<vtkImageCast>::New();
vtkSmartPointer<vtkImageData> atlasLabelImageData =
vtkSmartPointer<vtkImageData>::New();
imageCast->SetInput(atlasLabelsReader->GetOutput());
imageCast->SetOutputScalarTypeToUnsignedShort();
imageCast->Update();
atlasLabelImageData = imageCast->GetOutput();
unsigned long labelCellID = (unsigned short)
atlasLabelImageData->FindPoint(pickedPoint);
str.sprintf("(x, y, z) = (%3.2f, %3.2f, %3.2f), Label Value = %f",
pickedPoint[0], pickedPoint[1], pickedPoint[2], labelCellID);
--
Thanks,
Kannan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131105/743a13a6/attachment.htm>
More information about the vtkusers
mailing list