<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "><pre>David,</pre><pre><br></pre><pre>The iterator.IsAtEnd(); command is correct and is not the cause of</pre><pre><br></pre><pre>the crash but the fact that you are activating the offsets without</pre><pre><br></pre><pre>boundary checking can cause errors when you iterate over out of bound</pre><pre><br></pre><pre>pixels. To handle the boundary pixels more efficiently you should use</pre><pre><br></pre><pre>the FaceList which divides the image into boundary and non-boundary</pre><pre><br></pre><pre>regions so you won't have to check for boundaries. I took the liberty</pre><pre><br></pre><pre>of editing your code and also placed some comments, hope that
helps.</pre><pre><br></pre><pre>regards,</pre><pre><br></pre><pre>Dawood</pre><pre><br></pre><pre><br></pre><pre>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</pre><pre><br></pre><pre><span class="Apple-style-span" style="font-family: 'Times New Roman'; white-space: normal; "><pre>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</pre></span></pre><pre><br></pre><pre>Hi all,
I've been trying for quite a while to use the
ShapedNeighborhoodIterator. I want to move the pixels of a 4-connected
"cross" over the image. After looking through the examples and tests,
I came up with this:
<a href="http://www.vtk.org/Wiki/ITK/Examples/Broken/Images/ShapedNeighborhoodIterator">http://www.vtk.org/Wiki/ITK/Examples/Broken/Images/ShapedNeighborhoodIterator</a>
but it seems to crash when the iterator.IsAtEnd() function is called.
Stepping through that function, it seems like the center pixel is not
defined? I thought the iterator would take care of this? I tried
manually activating the "center" (0,0) offset, but it did not change
the behavior.
Can anyone see where I am going wrong?
Also, once this basic iteration works, what is the "correct" way to
handle the borders of image? For example, when iterating over the top
row of the image, the "top" pixel of the cross will be invalid. Do I
specify the region to iterate as the (width-1)(height-1) region
centered on the image, then manually reset the iterator to do the
top/bottom/left/right rows and columns manually (where this time in
the loop I know which pixels will be valid? Or is there a more
automatic way? I see that the neighborhoodIterator is templated on a
boundary condition, but it seems I would still have to do this:
// setup iterator with ConstantBoundaryCondition = -1
while(!iterator.IsAtEnd())
{
if(the pixel returns -1)
{ skip it because it is out of bounds}
}
I thought the whole point of handling the boundary condition in the
iterator is to not have to have a conditional in this inner loop?
Thanks,
David</pre></span></td></tr></table><br>