<div dir="ltr"><div><div>Sorry for the annoyances, but I've tested again my code (with pixel type to unsigned char) against another image with a few pixels with value 1 and it does not detect anyone.<br><br></div>However, in ITK, either with unsigned char or int, it always detects all the points to 1.<br><br></div>Thanks.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-24 13:04 GMT+02:00 Francisco Lopez de la Franca <span dir="ltr"><<a href="mailto:franciscolopezdelafranca@gmail.com" target="_blank">franciscolopezdelafranca@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi again,<br></div>I answer to myself in case it can help someone someday.<br></div>I've changed the voxel type to unsigned char and it works as expected, that is, instead of "int* voxel", I've changed it to "unsigned char* voxel". Only with this little change it works right.<br></div>Greetings.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-06-24 12:22 GMT+02:00 Francisco Lopez de la Franca <span dir="ltr"><<a href="mailto:franciscolopezdelafranca@gmail.com" target="_blank">franciscolopezdelafranca@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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.<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>/Francisco<br></div></font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>