[Insight-users] problems with itkErode/DilateImageFilters

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Dec 17 08:13:04 EST 2008


Le 17 déc. 08 à 13:13, Corinna Vehlow a écrit :

> Dear Gaëtan,
> thanks for all the tips, the BinaryBallStructuringElement works!
> But at the border of images (see attached pictures, the right one  
> with and the left one without post-processing), the results are not  
> satisfying, as the erosion can't take effect. Is there any way to  
> adjust the morphological filter, set a region of interest to perform  
> on, or to leave a border in each dimension of size (radius) and not  
> performing the morphological operation in that areas (bars).

You may want to use the new filters in the last ITK version, by  
turning on the CONSOLIDATED_MORPHOLOGY option in cmake when building  
ITK.
Within the new closing/opening and tophat filters, you will find a  
SafeBorderOn() method which makes the filter take care of the border  
problems.

   itk::GrayscaleMorphologicalClosingImageFilter::SafeBorderOn()
   itk::GrayscaleMorphologicalClosingImageFilter::SafeBorderOff()
   itk::GrayscaleMorphologicalClosingImageFilter::SetSafeBorder()
   itk::GrayscaleMorphologicalClosingImageFilter::GetSafeBorder()

Gaëtan

>
>
> Cheers
> Corinna
>
>
> The Institute of Cancer Research: Royal Cancer Hospital, a  
> charitable Company Limited by Guarantee, Registered in England under  
> Company No. 534147 with its Registered Office at 123 Old Brompton  
> Road, London SW7 3RP.
>
> This e-mail message is confidential and for use by the addressee  
> only.  If the message is received by anyone other than the  
> addressee, please return the message to the sender by replying to it  
> and then delete the message from your computer and network.<Snapshot  
> 2008-12-17 12-12-46.tiff>
>
>
> On 16 Dec 2008, at 4:53 PM, Gaëtan Lehmann wrote:
>
>>
>> Le 16 déc. 08 à 16:41, Corinna Vehlow a écrit :
>>
>>>
>>> On 16 Dec 2008, at 3:07 PM, Gaëtan Lehmann wrote:
>>>
>>>>
>>>> you can find it in the advanced options - it changes the filter  
>>>> for more optimized ones, but probably not as well tested.
>>>
>>> I found it, and its already set:
>>> #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
>>> #include "itkOptMorphologyImageFilter.h"
>>> #else
>>>
>>>>
>>>>
>>>> I mean a small example that we can build easily alone (without  
>>>> building slicer for example). The smallest is the best, as it  
>>>> makes easier to localize the problem.
>>>> Your code would be a great help, to begin.
>>>
>>> <RegionGrowingSegmentation.cxx>
>>>
>>>>
>>>>
>>>> Based on the random behavior you describe, I would think that you  
>>>> haven't properly initialized your structuring element.
>>>> Have you called the CreateStructuringElement() method every time  
>>>> you use a different structuring element size?
>>>
>>> There is no method called CreateStructuringElement() in non of the  
>>> itk.morphology-filters.
>>
>> This is a method from itk::BinaryBallStructuringElement - http://www.itk.org/Doxygen/html/classitk_1_1BinaryBallStructuringElement.html#2a5a566504ea25cfc756c09e9dccc121
>>
>>> I use dilateFilter->SetKernel(k). I create the kernel first via  
>>> using getKernel, which gives a standard empty kernel, which  
>>> includes the main structure, and then I just set the radius to the  
>>> value I need and the kernel is internally updated (I followed the  
>>> values when debugging).
>>
>> After updating the size of the kernel, you must update the content  
>> as well.
>>
>>> I've attached the code for the plugin.
>>
>> This peace of code is not enough:
>>
>>       KernelType dilKernel = dilateFilter->GetKernel();
>>       dilKernel.SetRadius(radius);
>>       dilateFilter->SetKernel(dilKernel);
>>
>> because the content is made of random data if the radius has changed.
>>
>> You should look at the ITK user guide (http://www.itk.org/ItkSoftwareGuide.pdf 
>> ), page 174, for an example with a ball structuring element. You  
>> may also find easier to use the itk::FlatStructuringElement class (http://www.itk.org/Doxygen/html/classitk_1_1FlatStructuringElement.html 
>> ) instead of the itk::Neighborhood you used as kernel type. To  
>> produce a valid structuring element, you just have to call
>>
>> dilateFilter->SetKernel( KernelType::Box(radius) );
>>
>> for a box, or
>>
>> dilateFilter->SetKernel( KernelType::Ball(radius) );
>>
>> for a ball, ... See http://voxel.jouy.inra.fr/darcs/contrib-itk/consolidatedMorphology/kernelShape.cxx 
>>  for an example.
>> However, to use it you have to turn ITK_USE_REVIEW on when building  
>> ITK.
>>
>> HTH,
>>
>> Gaëtan
>>
>>>
>>> Regards
>>> Corinna
>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Gaëtan
>>>>
>>>>>
>>>>> Regards
>>>>> Corinna
>>>>>
>>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Gaëtan
>>>>>>
>>>>>> -- 
>>>>>> Gaëtan Lehmann
>>>>>> Biologie du Développement et de la Reproduction
>>>>>> INRA de Jouy-en-Josas (France)
>>>>>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>>>>>> http://voxel.jouy.inra.fr  http://www.mandriva.org
>>>>>> http://www.itk.org  http://www.clavier-dvorak.org
>>>>>>
>>>>>> Le 16 déc. 08 à 12:29, Corinna Vehlow a écrit :
>>>>>>
>>>>>>> Hello everybody,
>>>>>>>
>>>>>>> I actually working at the Institute of Cancer Research on the  
>>>>>>> development of a plugin for the Slicer3 open source tool for  
>>>>>>> tumour segmentation. I'm using morphological operations as  
>>>>>>> post-processing to fill small gaps etc. I've tried the   
>>>>>>> itkGrayscaleErode/DilateImageFilter.h and itkErode/ 
>>>>>>> DilateObjectMorphologyImageFilter.h , both worked pretty well  
>>>>>>> on Windows, but now that I got a new machine (a MAC) at my  
>>>>>>> workplace, some problems occur. The results are not the same  
>>>>>>> in every case in comparison to the segmentation output, when  
>>>>>>> running the tool under Windows. The segmentation results  
>>>>>>> without any morphological operations are the same, but with  
>>>>>>> post-processing they are not. My post-processing consists of a  
>>>>>>> dilation first and erosion as second operation (so closing).  
>>>>>>> The weird thing is, that as long as I run my region growing  
>>>>>>> segmentation on a few number of seed points (max. 4), the  
>>>>>>> morphological operations are working correctly, and the  
>>>>>>> results of the post-processing are the same, as under Windows.  
>>>>>>> But if I select more then 4 (it doesn't matter which one I  
>>>>>>> select), the labels (segmented regions) are shrinking  
>>>>>>> extremely instead of growing or even disappearing at all, if  
>>>>>>> the region is small. Some times the whole label-map is empty  
>>>>>>> after post-processing.
>>>>>>>
>>>>>>> Can anybody help me or tell my how to fix this?
>>>>>>>
>>>>>>> Thanks a lot!
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> The Institute of Cancer Research: Royal Cancer Hospital, a  
>>>>> charitable Company Limited by Guarantee, Registered in England  
>>>>> under Company No. 534147 with its Registered Office at 123 Old  
>>>>> Brompton Road, London SW7 3RP.
>>>>>
>>>>> This e-mail message is confidential and for use by the addressee  
>>>>> only. If the message is received by anyone other than the  
>>>>> addressee, please return the message to the sender by replying  
>>>>> to it and then delete the message from your computer and network.
>>>>
>>>> -- 
>>>> Gaëtan Lehmann
>>>> Biologie du Développement et de la Reproduction
>>>> INRA de Jouy-en-Josas (France)
>>>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>>>> http://voxel.jouy.inra.fr  http://www.mandriva.org
>>>> http://www.itk.org  http://www.clavier-dvorak.org
>>>>
>>>
>>
>> -- 
>> Gaëtan Lehmann
>> Biologie du Développement et de la Reproduction
>> INRA de Jouy-en-Josas (France)
>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>> http://voxel.jouy.inra.fr  http://www.mandriva.org
>> http://www.itk.org  http://www.clavier-dvorak.org
>>
>

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.mandriva.org
http://www.itk.org  http://www.clavier-dvorak.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081217/0fe6f58c/attachment.pgp>


More information about the Insight-users mailing list