<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Dear all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal>I’m implementing a filter similar to the one found in Examples\Iterators\ShapedNeighborhoodIterators1.cxx<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[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.<o:p></o:p></p><p class=MsoNormal>However in the (inner) loop of the ShapedNeighborhoodIterator, no bounds are checked; instead all neighbors are visited (even those falling outside of the image).<o:p></o:p></p><p class=MsoNormal>How can I check for this?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>[2] In the (inner) loop of the ShapedNeighborhoodIterator, I can get the values of the pixels with ci.Get() .<o:p></o:p></p><p class=MsoNormal>How can I get the indexes? The GetIndex method does not work.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thank you for your time,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hugues<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here is my code:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>typedef</span> itk::ShapedNeighborhoodIterator< ImageType > ShapedNeighborhoodIteratorType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::OffsetType top = {{<span style='color:#FF8000'>0</span>,-<span style='color:#FF8000'>1</span>}};<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::OffsetType bottom = {{<span style='color:#FF8000'>0</span>,<span style='color:#FF8000'>1</span>}};<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::OffsetType left = {{-<span style='color:#FF8000'>1</span>,<span style='color:#FF8000'>0</span>}};<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::OffsetType right = {{<span style='color:#FF8000'>1</span>,<span style='color:#FF8000'>0</span>}};<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::RadiusType radius;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> radius.Fill( <span style='color:#FF8000'>1</span> );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>typedef</span> itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< ImageType > FaceCalculatorType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> FaceCalculatorType faceCalculator;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> FaceCalculatorType::FaceListType faceList;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> FaceCalculatorType::FaceListType::iterator faceListIterator;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> faceList = faceCalculator( inputImage, inputImage->GetRequestedRegion(), radius );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>for</span> ( faceListIterator=faceList.begin(); faceListIterator != faceList.end(); ++faceListIterator)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> std::cout << <span style='color:#A31515'>"Face group"</span> << std::endl;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType it( radius, reader->GetOutput(), *faceListIterator );<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>for</span> (it.GoToBegin(); !it.IsAtEnd(); ++it)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> std::cout << <span style='color:#A31515'>"Centre index: "</span> << it.GetIndex() << std::endl;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> it.ActivateOffset(top);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> it.ActivateOffset(bottom);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> it.ActivateOffset(left);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> it.ActivateOffset(right);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> ShapedNeighborhoodIteratorType::ConstIterator ci;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> std::cout << <span style='color:#A31515'>" Neighbor values: "</span>;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> <span style='color:blue'>for</span> (ci = it.Begin(); ci != it.End(); ci++)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> std::cout << ci.Get() << <span style='color:#A31515'>" "</span>; <span style='color:#00B050'>// All neighbors visited?!?, How to GetIndex() ?!?</span><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> std::cout << std::endl;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'> }</span><o:p></o:p></p></div></body></html>