Hello:<br><br>I'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'm not using the filters properly because the results don't look like the result of a close operation. Can someone point out to me what I'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'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<Pixel, 3> 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<Pixel, 3> Kernel;<br> // The dilation filter<br>
typedef DilateObjectMorphologyImageFilter<ImageType, ImageType, Kernel> DilateFilter;<br> // The erosion filter<br> typedef ErodeObjectMorphologyImageFilter<ImageType, ImageType, Kernel> ErodeFilter;<br>
<br> // Create the structuring element:<br> cout << "Creating structuring element ... " << flush;<br> Kernel ball;<br> ball.SetRadius(radius);<br> ball.CreateStructuringElement();<br>
cout << "done" << endl;<br>
<br> writeImage<ImageType>(image, "original.mhd");<br><br> // Now do the close operation<br> cout << "Dilating ... " << flush;<br> DilateFilter::Pointer closeDilate = DilateFilter::New();<br>
closeDilate->SetObjectValue(1);<br> closeDilate->SetKernel(ball);<br> closeDilate->SetInput(image);<br> closeDilate->Update();<br> cout << "done" << endl;<br> writeImage<ImageType>(closeDilate->GetOutput(), "dilated.mhd");<br>
<br> cout << "Eroding ... " << flush;<br> ErodeFilter::Pointer closeErode = ErodeFilter::New();<br> closeErode->SetObjectValue(1);<br> closeErode->SetKernel(ball);<br> closeErode->SetInput(closeDilate->GetOutput());<br>
closeErode->Update();<br> cout << "done" << endl;<br> writeImage<ImageType>(closeErode->GetOutput(), "closed.mhd");<br><br> return closeErode->GetOutput();<br>}<br>
<br>
<br clear="all">Rohit<br>