[Insight-users] problems with morphological close

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 6 20:48:16 EST 2010


Hi Rohit,


         Thanks for reporting this discrepancy.


Could you please post to the list that same image slice,
not as a screenshot, but as an image that we could use
to run a 2D test ?

In this way we will be able to replicate the problem...

or Even better,
Please log a bug in the bug tracker:

http://public.kitware.com/Bug/my_view_page.php

and add as attachment the input image in which
you are observing this issue.  The 3D image will
be ideal, but the 2D image could be ok.
(if you upload the 3D image, please mention in
the bug report, what slice number is the one in
which you are noticing the problem).


Also if you happen to have your code in a small
file that you could share, then it will be great if
you could attach that file to the bug report as well.


    Thanks


           Luis


-------------------------------------------------------------------------
On Tue, Mar 2, 2010 at 2:45 PM, Rohit Saboo <rohit at cs.unc.edu> wrote:
> As an interesting note, when I use BinaryDilateImageFilter and
> BinaryErodeImageFilter in place of DilateObjectMorphologyImageFilter and
> ErodeObjectMorphologyImageFilter, the images come out exactly as I expect.
> To me this is looking like a bug with DilateObjectMorphologyImageFilter and
> ErodeObjectMorphologyImageFilter.
>
> Rohit
>
>
> On Tue, Mar 2, 2010 at 11:24 AM, Rohit Saboo <rohit at cs.unc.edu> wrote:
>>
>> 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
>>>> 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>
>>>
>>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list