<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Hugues,<div><br></div><div>Welcome to the ITK mailing list :)</div><div><br></div><div>ImageBoundaryFacesCalculator divides the image into two main regions, boundary and</div><div><br></div><div>non-boundary. For the non-boundary region no bound checking will be performed and only</div><div><br></div><div>the pixels in boundary regions are bound checked. You can easily access the pixels in</div><div><br></div><div>those regions by neighborhood iterators, using the ImageBoundaryFacesCalculator will</div><div><br></div><div>save you the effort for bound checking. For more information take a look at the following</div><div><br></div><div>link,</div><div><br></div><div><a
href="http://www.itk.org/Doxygen/html/structitk_1_1NeighborhoodAlgorithm_1_1ImageBoundaryFacesCalculator.html">http://www.itk.org/Doxygen/html/structitk_1_1NeighborhoodAlgorithm_1_1ImageBoundaryFacesCalculator.html</a></div><div><br></div><div><br></div><div>The "ci" variable refers to the constant iterator which iterates over the neighborhood</div><div><br></div><div>defined by the neighborhood iterator and it does not have a GetIndex() method, instead</div><div><br></div><div>you can get its offset or neighborhood index and find its position relative to the center pixel</div><div><br></div><div>of the neighborhood. Page 722 of the ITK software guide illustrates how offsets and </div><div><br></div><div>neighborhood indexes are identified relative to the center pixel.</div><div><br></div><div>Hope this
helps,</div><div><br></div><div>Dawood</div><div><br></div><div><br></div><div>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</div><div><br></div><div>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</div><div><br></div><div><br></div><div><span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "><pre>Dear all,
It is my first post on the list and perhaps my question has already been
answered previously, albeit I couldn't find where. I'd be glad if you could
help even with a link.
I'm implementing a filter similar to the one found in
Examples\Iterators\ShapedNeighborhoodIterators1.cxx
[1] I understand that the advantage of the
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator is to lighten the burden
of the algorithm where no check for bounds is necessary.
However in the (inner) loop of the ShapedNeighborhoodIterator, no bounds are
checked; instead all neighbors are visited (even those falling outside of
the image).
How can I check for this?
[2] In the (inner) loop of the ShapedNeighborhoodIterator, I can get the
values of the pixels with ci.Get() .
How can I get the indexes? The GetIndex method does not work.
Thank you for your time,
Hugues
Here is my code:
typedef itk::ShapedNeighborhoodIterator< ImageType >
ShapedNeighborhoodIteratorType;
ShapedNeighborhoodIteratorType::OffsetType top = {{0,-1}};
ShapedNeighborhoodIteratorType::OffsetType bottom = {{0,1}};
ShapedNeighborhoodIteratorType::OffsetType left = {{-1,0}};
ShapedNeighborhoodIteratorType::OffsetType right = {{1,0}};
ShapedNeighborhoodIteratorType::RadiusType radius;
radius.Fill( 1 );
typedef itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<
ImageType > FaceCalculatorType;
FaceCalculatorType faceCalculator;
FaceCalculatorType::FaceListType faceList;
FaceCalculatorType::FaceListType::iterator faceListIterator;
faceList = faceCalculator( inputImage, inputImage->GetRequestedRegion(),
radius );
for ( faceListIterator=faceList.begin(); faceListIterator !=
faceList.end(); ++faceListIterator)
{
std::cout << "Face group" << std::endl;
ShapedNeighborhoodIteratorType it( radius, reader->GetOutput(),
*faceListIterator );
for (it.GoToBegin(); !it.IsAtEnd(); ++it)
{
std::cout << "Centre index: " << it.GetIndex() << std::endl;
it.ActivateOffset(top);
it.ActivateOffset(bottom);
it.ActivateOffset(left);
it.ActivateOffset(right);
ShapedNeighborhoodIteratorType::ConstIterator ci;
std::cout << " Neighbor values: ";
for (ci = it.Begin(); ci != it.End(); ci++)
{
std::cout << ci.Get() << " "; // All neighbors visited?!?, How to
GetIndex() ?!?
}
std::cout << std::endl;
}
}</pre></span></div></td></tr></table><br>