<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<DimX; i=i+Stepx)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">for(int j=0; j<DimY; i=j+Stepy)</font></p>
<p style="MARGIN: 0cm 0cm 10pt" class="MsoNormal"><font size="3" face="Calibri">for(int k=0; k<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"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></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 <<a href="mailto:anna.han.wan@gmail.com" target="_blank">anna.han.wan@gmail.com</a>> wrote:<br></div>
<div>
<div>> Hi all,<br>><br>> I am using NeighborhoodIterator to visit all voxels of my image(3D) and to<br>> do some processing within a rectangular neighborhood. As doing this is a<br>> time consuming process, I decided to move the iterator with an offset rather<br>
> than visiting every voxel. When I run my code I got the following error:<br>><br>><br>><br>> Unhandled exception at 0x000007fefcceaa7d in main.exe: Microsoft C++<br>> exception: itk::ExceptionObject at memory location 0x00b4f4a8.<br>
><br>><br>><br>> This is because the iterator has reached the image border. So my question is<br>> how can I increment the ierator with an offset and check at the same time if<br>> I reched the image border? I find the function InBounds but I don’t know<br>
> how to use it properly?<br>><br>><br>><br>><br>><br>><br>><br>><br>><br>> The relevent part of my code that the error is related to is as follows:<br>><br>><br>><br>> typedef itk::NeighborhoodIterator<ImageType> NeighborhoodIteratorType;<br>
><br>> NeighborhoodIteratorType It(radius, image,region);<br>><br>> It.NeedToUseBoundaryConditionOff();<br>><br>><br>><br>> NeighborhoodIteratorType::OffsetType ItOffset;<br>><br>> ItOffset.Fill(2);<br>
><br>><br>><br>><br>><br>> for ( It.GoToBegin(); !It.IsAtEnd(); It += ItOffset)<br>><br>> {<br>><br>><br>><br>> sum=0;<br>><br>> for(i = 0; i < It.Size(); i++)<br>
><br>> {<br>><br>> if (It.GetPixel(i)>0)<br>><br>> sum=sum+1;<br>><br>> }<br>><br>><br>><br>> }<br>><br>><br></div>
</div>> _____________________________________<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.html" target="_blank">http://www.kitware.com/products/protraining.html</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>