<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello,<div><br></div><div>The problem likely relates to defining the "white" box on a "back" background in terms of a binary image.</div><div><br></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></div><div>HTH,</div><div>Brad</div><div><br></div><div>[1] <a href="http://www.itk.org/Doxygen/html/classitk_1_1BinaryMorphologyImageFilter.html#aaf52178fc1fc4ffbc76a47d07c8c9fae">SetBackgroundValue</a></div><div>[2] <a href="http://www.itk.org/Doxygen/html/classitk_1_1BinaryMorphologyImageFilter.html#ac4bf6e82b67d062516a9512710e75d43">SetForegroundValue</a></div><div><br></div><div><br><div><div>On Aug 13, 2015, at 8:00 PM, Emma Ryan via Insight-users <<a href="mailto:insight-users@itk.org">insight-users@itk.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px; position: static; z-index: auto;"><div id="yui_3_16_0_1_1439510019394_2981">Hi,</div><div><br></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></div><div id="yui_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></div><div id="yui_3_16_0_1_1439510019394_3037"><br></div><div dir="ltr" id="yui_3_16_0_1_1439510019394_2982">typedef itk::FlatStructuringElement<2 > StructuralElementType;<br class="" id="yui_3_16_0_1_1439510019394_2999">StructuralElementType::RadiusType radius;<br class="" id="yui_3_16_0_1_1439510019394_3001">radius.Fill(7 );<br class="" id="yui_3_16_0_1_1439510019394_3003">StructuralElementType structural_element = StructuralElementType::Box( radius );<br class="" id="yui_3_16_0_1_1439510019394_3005"> <br class="" id="yui_3_16_0_1_1439510019394_3007"><br class="" id="yui_3_16_0_1_1439510019394_3009"> typedef itk::BinaryErodeImageFilter <UCharImageType, UCharImageType, StrelType> BinaryErodeImageFilterType;<br class="" id="yui_3_16_0_1_1439510019394_3011"> BinaryErodeImageFilterType::Pointer erodeFilter = BinaryErodeImageFilterType::New();<br class="" id="yui_3_16_0_1_1439510019394_3013"> erodeFilter->SetInput(my_binary_image);<br class="" id="yui_3_16_0_1_1439510019394_3015"> erodeFilter->SetKernel(structural_element);<br class="" id="yui_3_16_0_1_1439510019394_3017"> try<br class="" id="yui_3_16_0_1_1439510019394_3019"> {<br class="" id="yui_3_16_0_1_1439510019394_3021"> erodeFilter->Update();<br class="" id="yui_3_16_0_1_1439510019394_3023"> }<br></div><div dir="ltr" id="yui_3_16_0_1_1439510019394_2997">catch(...)</div><div id="yui_3_16_0_1_1439510019394_3117" dir="ltr">{</div><div id="yui_3_16_0_1_1439510019394_3118" dir="ltr"> cout<<"Failure";<br></div><div id="yui_3_16_0_1_1439510019394_3119" dir="ltr">}</div><div id="yui_3_16_0_1_1439510019394_3121" dir="ltr"><br></div><div id="yui_3_16_0_1_1439510019394_3123" dir="ltr">UCharImageType::Pointer new_image = erodeFilter->GetOutput();<br></div><div id="yui_3_16_0_1_1439510019394_3152" dir="ltr"><br></div><div id="yui_3_16_0_1_1439510019394_2996">thanks,</div><div id="yui_3_16_0_1_1439510019394_3153">Emma<br></div><div id="yui_3_16_0_1_1439510019394_3181"><br></div><div id="yui_3_16_0_1_1439510019394_2983"><br></div><div id="yui_3_16_0_1_1439510019394_3182"><br></div></div></div>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://public.kitware.com/mailman/listinfo/insight-users<br></blockquote></div><br></div></body></html>