<div dir="ltr">Thanks David for the pointer, it worked. I am setting the imageData variable from a metaImageReader so AllocateScalar wasn&#39;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">&lt;<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>&gt;</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 &lt;<a href="mailto:kannanuv@cshl.edu">kannanuv@cshl.edu</a>&gt; wrote:<br>

&gt; Hi,<br>
&gt; I am trying to find the value of a label at particular point in the image.<br>
&gt; The pickedPoint gives me the x,y,z co-ordinate where I should pick the<br>
&gt; value. How do I find the image value at that voxel? Since it is a label<br>
&gt; image I want to use nearest neighbor interpolation. Can anyone give me<br>
&gt; pointers of how to get the label value?<br>
&gt;<br>
&gt;<br>
&gt; vtkRenderWindowInteractor* iren =<br>
&gt; vtkRenderWindowInteractor::SafeDownCast(obj);<br>
&gt;<br>
&gt; iren-&gt;SetPicker(picker);<br>
&gt;<br>
&gt; // get event position<br>
&gt; int event_pos[2];<br>
&gt; iren-&gt;GetEventPosition(event_pos);<br>
&gt;<br>
&gt; // update label<br>
&gt; QString str;<br>
&gt;<br>
&gt; iren-&gt;GetPicker()-&gt;Pick(iren-&gt;GetEventPosition()[0],<br>
&gt; iren-&gt;GetEventPosition()[1], 0,<br>
&gt; iren-&gt;GetRenderWindow()-&gt;GetRenderers()-&gt;GetFirstRenderer());<br>
&gt; double pickedPoint[3];<br>
&gt; iren-&gt;GetPicker()-&gt;GetPickPosition(pickedPoint);<br>
&gt;<br>
&gt; vtkSmartPointer&lt;vtkImageCast&gt; imageCast =<br>
&gt; vtkSmartPointer&lt;vtkImageCast&gt;::New();<br>
&gt; vtkSmartPointer&lt;vtkImageData&gt; atlasLabelImageData =<br>
&gt; vtkSmartPointer&lt;vtkImageData&gt;::New();<br>
&gt;<br>
&gt; imageCast-&gt;SetInput(atlasLabelsReader-&gt;GetOutput());<br>
&gt; imageCast-&gt;SetOutputScalarTypeToUnsignedShort();<br>
&gt; imageCast-&gt;Update();<br>
&gt; atlasLabelImageData = imageCast-&gt;GetOutput();<br>
&gt; unsigned long labelCellID = (unsigned short)<br>
&gt; atlasLabelImageData-&gt;FindPoint(pickedPoint);<br>
&gt;<br>
&gt; str.sprintf(&quot;(x, y, z) = (%3.2f, %3.2f, %3.2f), Label Value = %f&quot;,<br>
&gt; pickedPoint[0], pickedPoint[1], pickedPoint[2], labelCellID);<br>
&gt;<br>
&gt; --<br>
&gt; Thanks,<br>
&gt; 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&#39;re looking for:<br>
<br>
double* pixel = static_cast&lt;double*&gt;(imageData-&gt;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-&gt;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>