<div>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">Thanks all for your relpy. </font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">I tried to resolve my problem but I find that I was digging in the wrong way.</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">What I want to do is something like the traditional image increment process :</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">// image (DimX,DimY,DimZ)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">for(int i=0; i&lt;DimX; i=i+Stepx)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">for(int j=0; j&lt;DimY; i=j+Stepy)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">for(int k=0; k&lt;DimZ; i=k+Stepz)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">{</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">Process the image at location (i,j,k)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">}</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">Moving the neighbourhood iterator<span style="mso-spacerun: yes">  </span>with an offset as in the loop <span style="mso-spacerun: yes"> </span>( It.GoToBegin(); !It.IsAtEnd();  It += ItOffset) does increment the iterator in the three direction (X,Y,Z) AT THE SAME TIME but what I am looking for is incrementing the iterator as the above loop (dimension by dimension).</font></p>

<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">I explain again my goal which is to compute some measures within the neighbourhood of image voxels. Neighbourhood iterator is good option but the problem is it is very very slow (it could take 1 hour or even more to process one image). <span style="mso-spacerun: yes"> </span>So to speed up this process I decided to compute the measures in only some location rather than doing this for every voxel.</font></p>

<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">Thank all for your time and help.</font></p></div>
<div><br> </div>
<div class="gmail_quote">On Mon, Dec 5, 2011 at 4:03 PM, Matt McCormick <span dir="ltr">&lt;<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi Anna,<br><br>You want to look at how ImageBoundaryFacesCalculator is used:<br><br><a href="http://www.itk.org/Doxygen/html/structitk_1_1NeighborhoodAlgorithm_1_1ImageBoundaryFacesCalculator.html" target="_blank">http://www.itk.org/Doxygen/html/structitk_1_1NeighborhoodAlgorithm_1_1ImageBoundaryFacesCalculator.html</a><br>
<br>Create one, then only iterate on region 0.<br><br>Matt<br>
<div><br>On Mon, Dec 5, 2011 at 10:57 AM, anna han wan &lt;<a href="mailto:anna.han.wan@gmail.com" target="_blank">anna.han.wan@gmail.com</a>&gt; wrote:<br></div>
<div>
<div>&gt; Hi all,<br>&gt;<br>&gt; I am using NeighborhoodIterator to visit all voxels of my image(3D) and to<br>&gt; do some processing within a rectangular neighborhood. As doing this is a<br>&gt; time consuming process, I decided to move the iterator with an offset rather<br>
&gt; than visiting every voxel. When I run my code I got the following error:<br>&gt;<br>&gt;<br>&gt;<br>&gt; Unhandled exception at 0x000007fefcceaa7d in main.exe: Microsoft C++<br>&gt; exception: itk::ExceptionObject at memory location 0x00b4f4a8.<br>
&gt;<br>&gt;<br>&gt;<br>&gt; This is because the iterator has reached the image border. So my question is<br>&gt; how can I increment the ierator with an offset and check at the same time if<br>&gt; I reched the image border?  I find the function InBounds but I don’t know<br>
&gt; how to use it properly?<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; The relevent part of my code that the error is related to is as follows:<br>&gt;<br>&gt;<br>&gt;<br>&gt; typedef itk::NeighborhoodIterator&lt;ImageType&gt; NeighborhoodIteratorType;<br>
&gt;<br>&gt; NeighborhoodIteratorType It(radius, image,region);<br>&gt;<br>&gt; It.NeedToUseBoundaryConditionOff();<br>&gt;<br>&gt;<br>&gt;<br>&gt; NeighborhoodIteratorType::OffsetType ItOffset;<br>&gt;<br>&gt; ItOffset.Fill(2);<br>
&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;       for ( It.GoToBegin(); !It.IsAtEnd();  It += ItOffset)<br>&gt;<br>&gt;       {<br>&gt;<br>&gt;<br>&gt;<br>&gt;             sum=0;<br>&gt;<br>&gt;             for(i = 0; i &lt; It.Size(); i++)<br>
&gt;<br>&gt;             {<br>&gt;<br>&gt;               if (It.GetPixel(i)&gt;0)<br>&gt;<br>&gt;                     sum=sum+1;<br>&gt;<br>&gt;             }<br>&gt;<br>&gt;<br>&gt;<br>&gt;       }<br>&gt;<br>&gt;<br></div>
</div>&gt; _____________________________________<br>&gt; Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br>&gt;<br>&gt; Visit other Kitware open-source projects at<br>&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>&gt; Kitware offers ITK Training Courses, for more information visit:<br>&gt; <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>&gt;<br>
&gt; Please keep messages on-topic and check the ITK FAQ at:<br>&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>&gt;<br>&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt;<br></blockquote></div><br>