[Insight-users] problems with morphological close

Gomez, Alberto alberto.gomez at kcl.ac.uk
Tue Mar 2 05:15:53 EST 2010


Hello,

I don't know if I had understood what you want to do. The original image 
you are using is "already closed", unless you want to link the two white 
figures. If that is the case, you wont be able to do that; a 
morphological close will only "fill" blanks or holes which are smaller 
than the  full figure (and that the structuring element). You are using 
an structuring element (ball) of size 1, which means that you will not 
be able to close spaces bigger than 1.

Apart from that, I think the results you are getting are coherent, 
although it is difficult to say without knowing the image resolution.

Please, can you explain in more detail what you expect to get?

Finally, If you want to close long and thin objects, the ball is 
probably not the best kernel, try something with the same shape as the 
object.

hth

Alberto


Rohit Saboo wrote:
> Hello:
>
> 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.
>
> Axial slices of the images (at the same position) are at the following locations:
> 1. original image   -  http://www.cs.unc.edu/~rohit/stuff/original.png
> 2. (intermediate) dilated image   -  http://www.cs.unc.edu/~rohit/stuff/dilated.png
> 3. (final) closed image   -  http://www.cs.unc.edu/~rohit/stuff/closed.png
>
> I'm including the parts of the code related to the close operation. The function below is called with a radius of 1.
>
> typedef unsigned short Pixel;
> typedef Image<Pixel, 3> ImageType;
> typedef ImageType::Pointer ImagePointer;
>
> ImagePointer closeImage( ImagePointer image, const unsigned int radius )
> {
>     // The ball structuring element:
>     typedef BinaryBallStructuringElement<Pixel, 3> Kernel;
>     // The dilation filter
>     typedef DilateObjectMorphologyImageFilter<ImageType, ImageType, Kernel> DilateFilter;
>     // The erosion filter
>     typedef ErodeObjectMorphologyImageFilter<ImageType, ImageType, Kernel> ErodeFilter;
>
>     // Create the structuring element:
>     cout << "Creating structuring element ... " << flush;
>     Kernel ball;
>     ball.SetRadius(radius);
>     ball.CreateStructuringElement();
>     cout << "done" << endl;
>
>     writeImage<ImageType>(image, "original.mhd");
>
>     // Now do the close operation
>     cout << "Dilating ... " << flush;
>     DilateFilter::Pointer closeDilate   = DilateFilter::New();
>     closeDilate->SetObjectValue(1);
>     closeDilate->SetKernel(ball);
>     closeDilate->SetInput(image);
>     closeDilate->Update();
>     cout << "done" << endl;
>     writeImage<ImageType>(closeDilate->GetOutput(), "dilated.mhd");
>
>     cout << "Eroding ... " << flush;
>     ErodeFilter::Pointer closeErode = ErodeFilter::New();
>     closeErode->SetObjectValue(1);
>     closeErode->SetKernel(ball);
>     closeErode->SetInput(closeDilate->GetOutput());
>     closeErode->Update();
>     cout << "done" << endl;
>     writeImage<ImageType>(closeErode->GetOutput(), "closed.mhd");
>
>     return closeErode->GetOutput();
> }
>
>
> Rohit
>
>   


-- 

Alberto Gómez

/Division of Imaging Sciences
The Rayne Institute
4th Floor, Lambeth Wing
St Thomas' Hospital
London SE1 7EH /

phone: +44 (0) 20 718 88364
email: alberto.gomez at kcl.ac.uk <mailto:alberto.gomez at kcl.ac.uk>



More information about the Insight-users mailing list