<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">Hi all,</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">I am using NeighborhoodIterator to visit all voxels of my image(3D) and to do some processing within a rectangular neighborhood. As doing this is a time consuming process, I decided to move the iterator with an offset rather than visiting every voxel. When I run my code I got the following error:<span style="mso-spacerun: yes"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">Unhandled exception at 0x000007fefcceaa7d in main.exe: Microsoft C++ exception: itk::ExceptionObject at memory location 0x00b4f4a8.</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">This is because the iterator has reached the image border. So my question is how can I increment the ierator with an offset and check at the same time if I reched the image border? <span style="mso-spacerun: yes"> </span>I find the function InBounds but I don’t know how to use it properly? </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">The relevent part of my code that the error is related to is as follows:</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">typedef</span><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> itk::NeighborhoodIterator<ImageType> NeighborhoodIteratorType;</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">NeighborhoodIteratorType It(radius, image,region);</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">It.NeedToUseBoundaryConditionOff();</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">NeighborhoodIteratorType::OffsetType ItOffset;</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">ItOffset.Fill(2);</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span><span style="COLOR: blue">for</span> ( It.GoToBegin(); !It.IsAtEnd();<span style="mso-spacerun: yes"> </span>It += ItOffset) </span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span>{<span style="mso-tab-count: 1"> </span><span style="mso-tab-count: 2"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 2"> </span>sum=0;</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 2"> </span><span style="COLOR: blue">for</span>(i = 0; i < It.Size(); i++)</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 2"> </span>{ <span style="mso-tab-count: 2"> </span><span style="mso-spacerun: yes"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-spacerun: yes"> </span><span style="mso-spacerun: yes"> </span><span style="COLOR: blue">if</span> (It.GetPixel(i)>0)<span style="mso-tab-count: 2"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 3"> </span><span style="mso-spacerun: yes"> </span>sum=sum+1;<span style="mso-tab-count: 3"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 2"> </span>}</span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span><span style="mso-tab-count: 1"> </span></span></p>
<p style="LINE-HEIGHT: normal; MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><span style="mso-tab-count: 1"> </span>}</span></p>