<div dir="ltr"><div><div>Hi everybody,<br></div>I've got a 3D image in NIFTI format. It is a binary image with 0 values for background and 1 values for objects.<br><br><br></div><div>I've coded a function to count the number of 1's in the image in the following way:<br><br>int* dims = _imageData->GetDimensions();<br><br>    int count= 0;<br>    int * voxel;<br>    for (int z = 0; z < dims[2]; z++)<br>    {<br>        for (int y = 0; y < dims[1]; y++)<br>        {<br>            for (int x = 0; x < dims[0]; x++)<br>            {<br>                voxel = static_cast<int*>(_imageData->GetScalarPointer(x,y,z));<br><br>                if ( voxel[0] == 1 ) {<br>                    count++;<br>                }<br>            }<br>        }<br>    }<br><br></div><div>However, this function does not detect any 1 in the image.<br><br></div><div>I've implemented another function in ITK, by using ITK image iterators, and the result is the expected. It detects hundreds of voxels with value 1 (also checked with the 3D Slicer tool).<br><br></div><div>Does anyone know what the problem could be in my VTK code? Does VTK provide iterators like ITK does?<br><br></div><div>Thank you very much.<br></div><div>My best regards.<br></div><div>/Francisco<br></div></div>