[Insight-users] problems with itkErode/DilateImageFilters

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Tue Dec 16 11:53:06 EST 2008


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

-------------- 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/20081216/8e578bd0/attachment.pgp>


More information about the Insight-users mailing list