<div dir="ltr"><div>Hi M.,</div><div><br></div><div>It doesn't look like you are doing anything wrong, so the first thing to do is make sure the reader actually read the image.  You can ask the reader to print the NIfTI header:</div><div><br></div><div>    readerVol->Update();</div><div>    readerVol->GetNIFTIHeader()->Print(std::cout);</div><div><br></div><div>Likewise, you can print info about the image to make sure the Extent is correct:</div><div><br></div><div>    readerVol->GetOutput()->Print(std::cout);</div><div><br></div><div>And you can get the range of values stored in the image to check whether they're all zero:</div><div><br></div><div>    double range[2];</div><div>    readerVol->GetOutput()->GetPointData()->GetScalars()->GetRange(range);</div><div>    std::cout << range[0] << ", " << range[1] << std::endl;</div><div><br></div><div>Hope this helps,</div><div>    David</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 25, 2019 at 8:18 AM M. Jordan <<a href="mailto:mjordan@live.at">mjordan@live.at</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi, <br>
<br>
I am using the vtkNIFTIImageReader to use Nifti files within VTK (e.g. for creating surfaces using marching cubes).<br>
Now I want to simply get the intensity of a certain voxel (e.g. 4 / 17 / 52). Nevertheless, I always get a value of zero.<br>
<br>
<span>vtkSmartPointer<vtkNIFTIImageReader> readerVol = vtkSmartPointer<vtkNIFTIImageReader>::New();<br>
</span>
<div>readerVol->SetFileName(image.toStdString().c_str());<br>
</div>
<span>readerVol->Update();</span><br>
<br>
<span>vtkSmartPointer<vtkImageData> volume = vtkSmartPointer<vtkImageData>:: New();<br>
</span><span>volume->DeepCopy(readerVol->GetOutput());</span><br>
<br>
float value = volume->GetScalarComponentAsFloat(4, 17, 52, 0);<br>
<br>
I also tried to do it like this: <a href="https://vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData" id="gmail-m_694450742014783349LPNoLP541099" target="_blank">
https://vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData</a>, but it is the same.<br>
<br>
When I load the image into an external Nifti viewer, the viewer shows the expected voxel intensity for the given voxel.<br>
<br>
What I am doing wrong?<br>
<br>
Thank you very much!<br>
Regards</div></div>
</blockquote></div></div>