[Insight-users] problems with morphological close

Rohit Saboo rohit at cs.unc.edu
Tue Mar 2 11:24:04 EST 2010


Hi Alberto,

I'll explain what I'm doing in a bit. It may not be best for the purpose
intended, however, the problem that I've observed still should not be there.
The closed structure always contains the original structure. However, if you
look closely at the images I have posted, the closed structure is thinner
than the original one.

The structure that I'm working with is a mandible. There are several issues
with these images - holes, teeth, etc. The slices that I've posted do not
have holes, but the error can be seen more easily here. Further, the
particular image that I produced is developed by a structuring element of
radius 1. I'll use structuring elements of larger radii if there are larger
holes.

The object is long and thin in some areas and blob-like in others. Further
the direction in which the object is thin is not constant; so, I feel that
using the same long thin structuring element everywhere may make things
worse.

Rohit


On Tue, Mar 2, 2010 at 5:15 AM, Gomez, Alberto <alberto.gomez at kcl.ac.uk>wrote:

> 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<http://www.cs.unc.edu/%7Erohit/stuff/original.png>
>> 2. (intermediate) dilated image   -
>> http://www.cs.unc.edu/~rohit/stuff/dilated.png<http://www.cs.unc.edu/%7Erohit/stuff/dilated.png>
>> 3. (final) closed image   -
>> http://www.cs.unc.edu/~rohit/stuff/closed.png<http://www.cs.unc.edu/%7Erohit/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>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100302/6e79e5a9/attachment.htm>


More information about the Insight-users mailing list