[vtk-developers] Fwd: Read Particular pixel value

Kannan U V kannanuv at cshl.edu
Tue Nov 5 14:19:11 EST 2013


---------- Forwarded message ----------
From: Kannan U V <kannanuv at cshl.edu>
Date: Tue, Nov 5, 2013 at 2:18 PM
Subject: Read Particular pixel value
To: vtkusers at vtk.org


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



-- 
Thanks,
Kannan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20131105/4b7f5385/attachment.html>


More information about the vtk-developers mailing list