[Insight-users] Create a Structuring Element from an image

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Mon Jun 29 15:13:11 EDT 2009


Hi Cyril,


Le 29 juin 09 à 19:16, Cyril Krykwinski a écrit :

> Dear insight-users,
>
> I would like to create a 3D Binary Cross Structuring Element, with  
> size = 3x3x1 (i.e. radius = 1x1x0)
>
> 1) I tried to define different radius with this code:
>
> //      typedef itk::BinaryCrossStructuringElement<unsigned char,3>   
> KernelType;
> //
> //      KernelType cross;
> //      KernelType::RadiusType crossRadius;
> //      crossRadius[0] = 1;
> //      crossRadius[1] = 1;
> //      crossRadius[2] = 0;
> //      cross.CreateStructuringElement();
> //
> //      typedef itk::BinaryDilateImageFilter  < InputImageType ,  
> OutputImageType , KernelType >  DilateFilterType;
> //      DilateFilterType::Pointer binaryDilate =  
> DilateFilterType::New( );
> //      binaryDilate->SetInput ( inputImage -> GetOutput( ) );
> //      binaryDilate->SetKernel ( cross);
> //      binaryDilate->SetDilateValue ( 255 );
>
> I tried also other radius, or to change the size with:
>
> //      KernelType::SizeType crossSize;
> //      crossSize[0] = 3;
> //      crossSize[1] = 3;
> //      crossSize[2] = 1;
>
> but I always obtain a dilation with size = 3x3x3 (i.e. radius = 1x1x1)
>

yes, BinaryCrossStructuringElement always produce a cross of size 3 on  
all the dimensions.

However, it should be possible to use

   itk::FlatStructuringElement<3>::Cross( crossSize )

to produce what you want.

> 2) I also tried to create my structuring element from an image (as  
> it was advised in a precedent message in this mailing list) which is  
> an image 3x3x1 whom pixels are =1 for (x=1) OR (y=1)
>
> imageKernal is the image 3x3x1 of my structuring element.
>
> //      typedef itk::FlatStructuringElement<3> SEType;
> //      SEType K;
> //      K = SEType::FromImage < InputImageType > ( imageKernel- 
> >GetOutput( ) );
> //      InputImageType ::Pointer kernelImage = K.GetImage <  
> InputImageType > ( );
> //
> //      binaryDilate->SetInput(unsignedCharImageContour->GetOutput());
> //      binaryDilate->SetKernel(kernelImage);
> //      binaryDilate->SetDilateValue( 255 );
>
> but FromImage is not a member of itk::FlatStructuringElement.
>

This method has been disabled when FlatStructuringElement has been  
moved in ITK, because templated functions are difficult to use with  
all the compilers supported by ITK.

http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Review/itkFlatStructuringElement.h?root=Insight&r1=1.6&r2=1.7
http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Review/itkFlatStructuringElement.txx?root=Insight&r1=1.4&r2=1.5

> So, is it possible to create our own 3D structuring element,  
> directly in ITK or from an image?
>

At this time, no.
But you can get the code from the diffs above, and move it to an  
helper class.
And it would be great to provide the result to the community!

Gaëtan

> Any help will be greatly appreciated,
>
> Best regards,
>
> Cyril.
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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

-- 
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.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090629/12537b9d/attachment.pgp>


More information about the Insight-users mailing list