<div dir="ltr">Thanks David for the pointer, it worked. I am setting the imageData variable from a metaImageReader so AllocateScalar wasn't necessary. <div><br></div><div>I thought I should mention this, even though my meta image was unsigned_short, the reader output was float. Is the functionality of every image reader?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 5, 2013 at 2:35 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Nov 5, 2013 at 2:18 PM, Kannan U V <<a href="mailto:kannanuv@cshl.edu">kannanuv@cshl.edu</a>> wrote:<br>
> Hi,<br>
> I am trying to find the value of a label at particular point in the image.<br>
> The pickedPoint gives me the x,y,z co-ordinate where I should pick the<br>
> value. How do I find the image value at that voxel? Since it is a label<br>
> image I want to use nearest neighbor interpolation. Can anyone give me<br>
> pointers of how to get the label value?<br>
><br>
><br>
> vtkRenderWindowInteractor* iren =<br>
> vtkRenderWindowInteractor::SafeDownCast(obj);<br>
><br>
> iren->SetPicker(picker);<br>
><br>
> // get event position<br>
> int event_pos[2];<br>
> iren->GetEventPosition(event_pos);<br>
><br>
> // update label<br>
> QString str;<br>
><br>
> iren->GetPicker()->Pick(iren->GetEventPosition()[0],<br>
> iren->GetEventPosition()[1], 0,<br>
> iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer());<br>
> double pickedPoint[3];<br>
> iren->GetPicker()->GetPickPosition(pickedPoint);<br>
><br>
> vtkSmartPointer<vtkImageCast> imageCast =<br>
> vtkSmartPointer<vtkImageCast>::New();<br>
> vtkSmartPointer<vtkImageData> atlasLabelImageData =<br>
> vtkSmartPointer<vtkImageData>::New();<br>
><br>
> imageCast->SetInput(atlasLabelsReader->GetOutput());<br>
> imageCast->SetOutputScalarTypeToUnsignedShort();<br>
> imageCast->Update();<br>
> atlasLabelImageData = imageCast->GetOutput();<br>
> unsigned long labelCellID = (unsigned short)<br>
> atlasLabelImageData->FindPoint(pickedPoint);<br>
><br>
> str.sprintf("(x, y, z) = (%3.2f, %3.2f, %3.2f), Label Value = %f",<br>
> pickedPoint[0], pickedPoint[1], pickedPoint[2], labelCellID);<br>
><br>
> --<br>
> Thanks,<br>
> Kannan<br>
<br>
<br>
</div></div>This kind of question is appropriate for the vtk-users list - the<br>
developers list is reserved for questions about the internals of VTK.<br>
<br>
I think you're looking for:<br>
<br>
double* pixel = static_cast<double*>(imageData->GetScalarPointer(x,y,z));<br>
<br>
where that type (double) should match the type of your image (e.g. in<br>
this case the image should have been allocated with<br>
imageData->AllocateScalars(VTK_DOUBLE,1);)<br>
<br>
There is a example that demonstrates this type of access here:<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData</a><br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks,<br>Kannan
</div>