Hi Erkang,<br><br>Most of the Iterators in ITK are pre-set to <br>advance by one only.<br><br>You may find easier to implement this by <br>directly controlling the index, with code <br>such as:<br><br>SizeType size = region.GetSize();<br>
IndexType index = region.GetIndex();<br><br><div>for (int z=0; z<size[2]; z+=step_z)<br> {<br> index[2] = z;<br></div><div>
for (int y=0; y<size[1], y+step_y)<br> {<br></div><div> index[1] = y;<br> for(int x=0; x<size[0]; x+=step_x)</div><div> {<br> index[0] = x;<br> PixelType value = image->GetPixel( index );<br>
</div><div> // calculate response at (x,y,z)</div><div> }<br> }<br> }<br></div>
<div><br><br>The disadvantage is that this is not very fast<br>at run time... so, if you need something to <br>perform at high speed, it might be worth to<br>customize one of the existing Iterators, for<br>example the SliceIteratorWithIndex:<br>
<br><a href="http://www.itk.org/Doxygen/html/classitk_1_1ImageSliceConstIteratorWithIndex.html">http://www.itk.org/Doxygen/html/classitk_1_1ImageSliceConstIteratorWithIndex.html</a><br></div><br>The modifications may not be trivial though....<br>
<br><br>Yet another option is to simply use the ShrinkImageFilter,<br><a href="http://www.itk.org/Doxygen/html/classitk_1_1ShrinkImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1ShrinkImageFilter.html</a><br>
<br>to first sub-sample the image by the steps that you <br>want to use in X,Y and Z, and then use a standard <br>iterator on the sub-sampled image.<br><br><br> Luis<br><br><br>------------------------------------------------------<br>
<div class="gmail_quote">On Wed, May 23, 2012 at 4:17 PM, Erkang Cheng <span dir="ltr"><<a href="mailto:ekyaya@gmail.com" target="_blank">ekyaya@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi everyone:<div><br></div><div>I want to loop over the image domain by increasing specific steps along each direction.</div><div><br></div><div>Which iterator is appropriated for my case?</div><div><br></div><div>I want to realize the following nest loop:</div>
<div><br></div><div>The image size is size_x, size_y, size_z;</div><div><br></div><div>And the steps I want to increase are: step_x, step_y, step_z;</div><div><br></div><div>for (int z=0; z<size_z; z+=step_z)</div><div>
for (int y=0; y<size_y, y+step_y)</div><div> for(int x=0; x<size_x; x+=step_x)</div><div> {</div><div> // calculate response at (x,y,z)</div><div> }</div>
<div><br></div><div>Is there similar example for me to follow? Thanks. </div><div><br></div><div>Best</div><span class="HOEnZb"><font color="#888888"><div>Erkang</div>
</font></span><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>