<div class="gmail_quote">On Mon, Mar 21, 2011 at 10:32 AM, Hugues Fontenelle <span dir="ltr"><<a href="mailto:hugues.fontenelle@rr-research.no">hugues.fontenelle@rr-research.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Dear Insight Users,</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thank you Dawood and David,</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Re-reading the material that you advised was useful, and I can now rephrase my question correctly:</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">“<b>How do I set up boundary conditions for neighbor iterators?”</b> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I did find the answer though! I thought that it would be useful to post it here. Perhaps the example codes can be updated? I’m a bit afraid of messing that up so I leave it to you. In the meantime here is the tricks.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">By default, the boundary conditions are set to Neumann, i.e. the first derivative across the boundary is zero.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">However there are cases where you want a constant boundary, i.e. pad the image with zeros. Then the iterator type should be : </span></p><p class="MsoNormal">
<span style="font-size:11.0pt;color:#1F497D"> </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::ConstantBoundaryCondition< ImageType > BoundaryConditionType;</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::ShapedNeighborhoodIterator< ImageType, BoundaryConditionType > ShapedNeighborhoodIteratorType;</span><span style="font-size:11.0pt;color:#1F497D"></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Now out-of-bounds pixels will return zero.</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">For another constant value (such as -1) I use the following:</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </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::ConstantBoundaryCondition< ImageType > BoundaryConditionType;</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New""> BoundaryConditionType BoundaryCondition ;</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> BoundaryCondition.SetConstant( -<span style="color:#FF8000">1</span> );</span><span style="font-size:11.0pt;color:#1F497D"></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">And later apply it the neighbor iterator:</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""> it.OverrideBoundaryCondition(&BoundaryCondition);</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I hope it helps someone else.</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Regards</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Hugues.</span></p></div></div></blockquote><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8">Hugues,</div>
<div class="gmail_quote"><br>Great! I'm glad you figured it out. We certainly appreciate you reporting back as you did so that others with the same problem will have somewhere to start. As for being "afraid of messing up" the wiki - don't be! It keeps an infinite revision history so if you really break something we can always go back to a previous version. In this case, I think your addition is worth adding a new example rather than revising an old one. Maybe something like "NeighborhoodIteratorWithBoundaryCondition" or similar. If you want to, give it a shot! If you have any questions or concerns don't hesitate to let me know. Having this set of examples maintained by everyone is critical to its success!</div>
<div class="gmail_quote"><br clear="all">Thanks,<br><br><div>David</div></div>