<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div>Hi Brad,</div><div><br></div><div id="yui_3_16_0_1_1439528666543_3583" dir="ltr">Thanks for your reply.  Unfortunately, this does not seem to be the case.  I think by default, the foreground is considered to be the highest value in the input image. Nonetheless, I did try to set both the values, but the filter still fails to erode the image.</div><div id="yui_3_16_0_1_1439528666543_4344" dir="ltr"><br></div><div id="yui_3_16_0_1_1439528666543_4343" dir="ltr">thanks,</div><div id="yui_3_16_0_1_1439528666543_4109" dir="ltr">Emma<br></div><div id="yui_3_16_0_1_1439528666543_4085" dir="ltr"><br></div><div id="yui_3_16_0_1_1439528666543_3141"><span></span></div>  <br><div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"> <font face="Arial" size="2"> On Thursday, August 13, 2015 5:18 PM, Bradley Lowekamp <blowekamp@mail.nih.gov> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container"><div id="yiv8620436668"><div>Hello,<div><br clear="none"></div><div>The problem likely relates to defining the "white" box  on a "back" background in terms of a binary image.</div><div><br clear="none"></div><div>You should set the "BackgroundValue"[1] and the "ForegroundValue"[2] in the filter to you "white" pixel intensity value, and "black" pixel intensity value. Those methods a little tricky to find since they are in the parent class. Be careful to note if there are pixels of other values in the image.</div><div><br clear="none"></div><div>HTH,</div><div>Brad</div><div><br clear="none"></div><div>[1] <a rel="nofollow" shape="rect" target="_blank" href="http://www.itk.org/Doxygen/html/classitk_1_1BinaryMorphologyImageFilter.html#aaf52178fc1fc4ffbc76a47d07c8c9fae">SetBackgroundValue</a></div><div>[2] <a rel="nofollow" shape="rect" target="_blank" href="http://www.itk.org/Doxygen/html/classitk_1_1BinaryMorphologyImageFilter.html#ac4bf6e82b67d062516a9512710e75d43">SetForegroundValue</a></div><div><br clear="none"></div><div class="yiv8620436668yqt6489055800" id="yiv8620436668yqt23368"><div><br clear="none"><div><div>On Aug 13, 2015, at 8:00 PM, Emma Ryan via Insight-users <<a rel="nofollow" shape="rect" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>> wrote:</div><br class="yiv8620436668Apple-interchange-newline" clear="none"><blockquote type="cite">

</blockquote></div></div></div></div><div class="yiv8620436668yqt6489055800" id="yiv8620436668yqt22495"><div><div><div style="background-color:rgb(255, 255, 255);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;"><div id="yiv8620436668yui_3_16_0_1_1439510019394_2981">Hi,</div><div><br clear="none"></div><div> I am attempting a simple erosion on a binary input image which is pretty much a white box on a black background.</div><div><br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_3178"> The following is my code snippet. Not sure why it fails to erode the image. Am I missing something ? <br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_3037"><br clear="none"></div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_2982">typedef itk::FlatStructuringElement<2 >    StructuralElementType;<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_2999" clear="none">StructuralElementType::RadiusType radius;<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3001" clear="none">radius.Fill(7 );<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3003" clear="none">StructuralElementType structural_element =   StructuralElementType::Box( radius );<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3005" clear="none">    <br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3007" clear="none"><br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3009" clear="none">    typedef itk::BinaryErodeImageFilter <UCharImageType, UCharImageType, StrelType>    BinaryErodeImageFilterType;<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3011" clear="none">    BinaryErodeImageFilterType::Pointer erodeFilter    = BinaryErodeImageFilterType::New();<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3013" clear="none">    erodeFilter->SetInput(my_binary_image);<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3015" clear="none">    erodeFilter->SetKernel(structural_element);<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3017" clear="none">    try<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3019" clear="none">    {<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3021" clear="none">        erodeFilter->Update();<br class="yiv8620436668" id="yiv8620436668yui_3_16_0_1_1439510019394_3023" clear="none">    }<br clear="none"></div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_2997">catch(...)</div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3117">{</div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3118">    cout<<"Failure";<br clear="none"></div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3119">}</div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3121"><br clear="none"></div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3123">UCharImageType::Pointer new_image = erodeFilter->GetOutput();<br clear="none"></div><div dir="ltr" id="yiv8620436668yui_3_16_0_1_1439510019394_3152"><br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_2996">thanks,</div><div id="yiv8620436668yui_3_16_0_1_1439510019394_3153">Emma<br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_3181"><br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_2983"><br clear="none"></div><div id="yiv8620436668yui_3_16_0_1_1439510019394_3182"><br clear="none"></div></div></div>_____________________________________<br clear="none">Powered by <a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br clear="none"><br clear="none">Visit other Kitware open-source projects at<br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br clear="none"><br clear="none">Kitware offers ITK Training Courses, for more information visit:<br clear="none">http://www.kitware.com/products/protraining.php<br clear="none"><br clear="none">Please keep messages on-topic and check the ITK FAQ at:<br clear="none">http://www.itk.org/Wiki/ITK_FAQ<br clear="none"><br clear="none">Follow this link to subscribe/unsubscribe:<br clear="none">http://public.kitware.com/mailman/listinfo/insight-users<br clear="none"><br clear="none"></div></div></div><br><br></div>  </div> </div>  </div></div></body></html>