Hello:<br><br>I&#39;m trying to do a morphological close by dilating the input image and then following it with the input image. However, it seems that I&#39;m not using the filters properly because the results don&#39;t look like the result of a close operation. Can someone point out to me what I&#39;m doing wrong.<br>

<br>Axial slices of the images (at the same position) are at the following locations:<br>1. original image   -  <a href="http://www.cs.unc.edu/~rohit/stuff/original.png">http://www.cs.unc.edu/~rohit/stuff/original.png</a><br>

2. (intermediate) dilated image   -  <a href="http://www.cs.unc.edu/~rohit/stuff/dilated.png">http://www.cs.unc.edu/~rohit/stuff/dilated.png</a><br>3. (final) closed image   -  <a href="http://www.cs.unc.edu/~rohit/stuff/closed.png">http://www.cs.unc.edu/~rohit/stuff/closed.png</a><br>

<br>I&#39;m including the parts of the code related to the close operation. The function below is called with a radius of 1.<br><br>typedef unsigned short Pixel;<br>typedef Image&lt;Pixel, 3&gt; ImageType;<br>typedef ImageType::Pointer ImagePointer;<br>

<br>ImagePointer closeImage( ImagePointer image, const unsigned int radius )<br>{<br>    // The ball structuring element:<br>    typedef BinaryBallStructuringElement&lt;Pixel, 3&gt; Kernel;<br>    // The dilation filter<br>

    typedef DilateObjectMorphologyImageFilter&lt;ImageType, ImageType, Kernel&gt; DilateFilter;<br>    // The erosion filter<br>    typedef ErodeObjectMorphologyImageFilter&lt;ImageType, ImageType, Kernel&gt; ErodeFilter;<br>

<br>    // Create the structuring element:<br>    cout &lt;&lt; &quot;Creating structuring element ... &quot; &lt;&lt; flush;<br>    Kernel ball;<br>    ball.SetRadius(radius);<br>    ball.CreateStructuringElement();<br>
    cout &lt;&lt; &quot;done&quot; &lt;&lt; endl;<br>
<br>    writeImage&lt;ImageType&gt;(image, &quot;original.mhd&quot;);<br><br>    // Now do the close operation<br>    cout &lt;&lt; &quot;Dilating ... &quot; &lt;&lt; flush;<br>    DilateFilter::Pointer closeDilate   = DilateFilter::New();<br>

    closeDilate-&gt;SetObjectValue(1);<br>    closeDilate-&gt;SetKernel(ball);<br>    closeDilate-&gt;SetInput(image);<br>    closeDilate-&gt;Update();<br>    cout &lt;&lt; &quot;done&quot; &lt;&lt; endl;<br>    writeImage&lt;ImageType&gt;(closeDilate-&gt;GetOutput(), &quot;dilated.mhd&quot;);<br>

<br>    cout &lt;&lt; &quot;Eroding ... &quot; &lt;&lt; flush;<br>    ErodeFilter::Pointer closeErode = ErodeFilter::New();<br>    closeErode-&gt;SetObjectValue(1);<br>    closeErode-&gt;SetKernel(ball);<br>    closeErode-&gt;SetInput(closeDilate-&gt;GetOutput());<br>

    closeErode-&gt;Update();<br>    cout &lt;&lt; &quot;done&quot; &lt;&lt; endl;<br>    writeImage&lt;ImageType&gt;(closeErode-&gt;GetOutput(), &quot;closed.mhd&quot;);<br><br>    return closeErode-&gt;GetOutput();<br>}<br>

<br>
<br clear="all">Rohit<br>