[Insight-users] Modify a ball Structuring Element

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Apr 16 05:53:06 EDT 2008


Hi Irene,

You can find an example in kernelShape.cxx. The relevant part is:

     typedef itk::ImageFileReader< IType > ReaderType;
     ReaderType::Pointer reader = ReaderType::New();
     reader->SetFileName( argv[4] );
     K = SEType::FromImage<IType>( reader->GetOutput() );

where K is the resulting structuring element. This code should fit  
your needs.

Regards,

Gaëtan



Le 15 avr. 08 à 18:58, Irene Gonzálvez García a écrit :
> Hi Gaëtan ,
>
> Thank you very much for your help. I've reading the article and I  
> found it really interesting. Currently, I have some questions  
> regarding the function FromImage() because I couldn't see any  
> published example. I have implemented a structuring element in  
> Matlab and it has been saved as an image with extension . mhd (the  
> header) and .raw (the data) which will be passed as an argument in  
> the command line. How can I relation this image with the argument of  
> the FromImage() ? Because as I saw in the definition, the argument  
> should be a pointer. Are there any examples? Is it correct this  
> extension for the argument of this function?. Here, I attach my  
> code. It's just a dilatation using as the structuring element the  
> one I've created.
>
>
> int main( int argc, char * argv[] )
> {
>   if( argc < 4 )
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << "  inputImageFile ";
>     std::cerr << " outputImageFileDilation structuringelement" <<  
> std::endl;
>     return EXIT_FAILURE;
>     }
>   const unsigned int Dimension = 2;
>
>   typedef unsigned char   InputPixelType;
>   typedef unsigned char   OutputPixelType;
>
>   typedef itk::Image< InputPixelType,  Dimension >   InputImageType;
>   typedef itk::Image< OutputPixelType, Dimension >   OutputImageType;
>
>   typedef itk::ImageFileReader< InputImageType  >  ReaderType;
>   typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>
>   typedef itk::FlatStructuringElement< Dimension >  
> StructuringElementType;
>
>   typedef itk::GrayscaleDilateImageFilter<InputImageType,  
> OutputImageType, StructuringElementType >  DilateFilterType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writerDilation = WriterType::New();
>   DilateFilterType::Pointer grayscaleDilate = DilateFilterType::New();
>   InputImageType::Pointer structu = InputImageType::New();
>
>   StructuringElementType structuringelement;
>   InputImageType::PixelType foreground=itk::NumericTraits<   
> InputImageType::PixelType >::max();
>   structuringelement.FromImage<InputImageType>(structu, foreground);
>
>   grayscaleDilate->SetKernel( structuringelement );
>
>   reader->SetFileName( argv[1] );
>   writerDilation->SetFileName( argv[2] );
>
>   grayscaleDilate->SetInput( reader->GetOutput() );
>
>   writerDilation->SetInput( grayscaleDilate->GetOutput() );
>   writerDilation->Update();
>
>
>   return EXIT_SUCCESS;
> }
>
>
> Thank you very much for your help
> Best regards
> Irene
>
> Gaëtan Lehmann wrote:
>>
>>
>> Hi Irene,
>>
>> You may be interested in the methods in the FlatStructuringElement  
>> made to transform an image to a structuring element, and a  
>> structuring element to an image.
>> That way, you can prepare easy a complex structuring element in an  
>> image, or check the structuring element shape visually.
>>
>> You will find the FlatStructuringElement class in the article  
>> "Efficient implementation of kernel filtering" on the Insight  
>> Journal.
>>
>> Regards,
>>
>> Gaëtan
>>
>>
>>
>> Le 13 avr. 08 à 23:14, Irene Gonzálvez García a écrit :
>>> Dear all insight-users,
>>> I would like to create a Binary Ball Structuring element with N- 
>>> dimensions. If we suppose that we have a 2D structuring element  
>>> with radius equals to 1 (size = 3x3),  I would like to make zero  
>>> the first column (page 722, itkSoftwareGuide). Basically, we have  
>>> always a odd number of columns. In the middle one, the center of  
>>> the Structuring Element is located.I would like to make zero all  
>>> columns which are in the left side of the central column. I tried  
>>> to modify part of the code in itkBinaryBallStructuringElement but  
>>> I don't get the expected result. When I write sfi.GoToBegin(), I  
>>> think the pixel which is modified is the central one, not the  
>>> upper-left pixel.
>>>
>>> Please, could you give me any suggestions how to do it?
>>> Best regards
>>> Irene
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> 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.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/20080416/f8c3c020/attachment.pgp>


More information about the Insight-users mailing list