[Insight-users] Re: help with wrapping of itkVoronoiSegmentationImageFilter

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 14 22:26:51 EST 2004


Hi Bruno,


In response to your request we just wrote a short Tutorial
on how to wrap an additional ITK class.

You will find it in the Wiki pages:

             http://www.itk.org/Wiki/ITK

more specifically in

       http://www.itk.org/Wiki/ITK_Scripting

and

http://www.itk.org/Wiki/ITK_Scripting#How_to_wrap_additional_classes



The example used in this short tutorial is (not a coincidence)
the OtsuMultipleThresholdCalculator.

So, if you follow the steps indicated in the tutorial you should
be able to wrap this class without any major difficulty.

This will also show you how to proceed with the other classes.

Note that the DeformableMesh3D will be a more challenging class to
wrap since the ITK Mesh is very heavily templated.  You may want to
leave this class for the end, when you have more confidence on how
to extend the wrapping.


Please follow the tutorial and let us know if you find any problem,



    Thanks



       Luis



------------------------------------------------
Bruno Cassaro wrote:

> Luis I had update my CVS checkout and rebuild it. Now every thing is going
> fine, but now I want to use OtsuMultipleThresholdCalculator,
> STAPLEImageFilter, DeformaMesh3Dfilter, BinaryMaskMeshSource and
> AntiAliasBinaryImageFilter.
> 
> How could I wrap this classes to Python ???
> 
> Thanks,
> 
> Bruno Cassaro
> 
> ----- Original Message ----- 
> From: "Luis Ibanez" <luis.ibanez at kitware.com>
> To: "Bruno Cassaro" <bcdalava at cenpra.gov.br>
> Cc: <insight-users at itk.org>
> Sent: Tuesday, November 09, 2004 7:59 PM
> Subject: Re: [Insight-users] Re: help with wrapping of
> itkVoronoiSegmentationImageFilter
> 
> 
> 
>>Hi Bruno,
>>
>>
>>You probably missed that we already added the
>>VoronoiSegmentationFilter to the wrapping.
>>
>>
> 
> http://www.itk.org/cgi-bin/viewcvs.cgi/Wrapping/CSwig/Algorithms/wrap_itkVoronoiSegmentationImageFilter.cxx?rev=1.1&root=Insight&sortby=date&view=log
> 
>>
>>You just need to update your CVS checkout and
>>rebuild it. Note that you don't need to rebuild
>>from scratch nor do a 'make clean', just do 'make'
>>and the extra classes should be wrapped.
>>
>>
>>You may want to use the test example that we added
>>in the CMakeLists.txt file in
>>
>>   Insight/Testing/Code/Algorithms
>>
>>
>>Note that this test is using as input the images in
>>
>>
>>        Insight/Examples/Data
>>
>>
>>
>>Please let us know if you find any problems,
>>
>>
>>    Thanks
>>
>>
>>      Luis
>>
>>
>>
>>---------------------
>>Bruno Cassaro wrote:
>>
>>
>>>Thanks a lot Luiz for your answer!
>>>
>>>I tried to Solve my problems with your propositions and I still have few
>>>doubts.
>>>
>>>
>>>When I use the three steps process for adding a class to wrapping and
>>>rebuild my project , na error appear from
>>>itkVoronoiSegmentationImageFilterBase and itkVononoiDiagram2D. Error
> 
> Code
> 
>>>{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fswiss\fcharset0
>>>Arial;}}
>>>
>>>{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20
> 
> Building
> 
>>>wrap_ITKAlgorithmsPython.xml from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1\\Wrapping\\CSwig\\Algorithms\\wrap_ITKAlgo
> 
>>>rithmsPython.cxx\par
>>>
>>>Building wrap_ITKAlgorithmsPython.idx from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1_bin\\Wrapping\\CSwig\\Algorithms\\wrap_ITK
> 
>>>AlgorithmsPython.idx.rule\par
>>>
>>>Building wrap_ITKAlgorithmsPythonPython.cxx from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1_bin\\Wrapping\\CSwig\\Algorithms\\wrap_ITK
> 
>>>AlgorithmsPythonPython.cxx.rule\par
>>>
>>>create swig package ITKAlgorithmsPython\par
>>>
>>>init module: itkCurvatureFlowImageFilter\par
>>>
>>>init module: itkDemonsRegistrationFilter\par
>>>
>>>init module: itkHistogramMatchingImageFilter\par
>>>
>>>init module: itkImageRegistrationMethod\par
>>>
>>>init module: itkImageToImageMetric\par
>>>
>>>init module: itkMeanSquaresImageToImageMetric\par
>>>
>>>init module: itkMutualInformationImageToImageMetric\par
>>>
>>>init module: itkMultiResolutionImageRegistrationMethod\par
>>>
>>>init module: itkNormalizedCorrelationImageToImageMetric\par
>>>
>>>init module: itkOtsuThresholdImageCalculator\par
>>>
>>>init module: itkMeanReciprocalSquareDifferenceImageToImageMetric\par
>>>
>>>init module: itkThresholdSegmentationLevelSetImageFilter\par
>>>
>>>init module: itkGeodesicActiveContourLevelSetImageFilter\par
>>>
>>>init module: itkShapeDetectionLevelSetImageFilter\par
>>>
>>>init module: itkCurvesLevelSetImageFilter\par
>>>
>>>init module: itkNarrowBandLevelSetImageFilter\par
>>>
>>>init module: itkNarrowBandCurvesLevelSetImageFilter\par
>>>
>>>init module: itkMattesMutualInformationImageToImageMetric\par
>>>
>>>init module: itkPDEDeformableRegistrationFilter\par
>>>
>>>init module: itkRecursiveMultiResolutionPyramidImageFilter\par
>>>
>>>init module: itkVoronoiSegmentationImageFilter\par
>>>
>>>init module: itkWatershedImageFilter\par
>>>
>>>Building wrap_itkVoronoiSegmentationImageFilterPython.cxx from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1_bin\\Wrapping\\CSwig\\Algorithms\\wrap_itk
> 
>>>VoronoiSegmentationImageFilterPython.cxx.rule\par
>>>
>>>Warning itk::Mesh<double,2,itk::DefaultDynamicMeshTraits<double, 2, 2,
>>>double, float, double> >\par
>>>
>>>has a class hierarchy that has wrapping gaps.\par
>>>
>>>The class hierarchy wrapping is as follows:\par
>>>
>>>Not wrapped:
>>>
> 
> itk::PointSet<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,flo
> 
>>>at,double)>)>\par
>>>
>>>Wrapped: itk::DataObject\par
>>>
>>>Wrapped: itk::Object\par
>>>
>>>Wrapped: itk::LightObject\par
>>>
>>>Warning itk::VoronoiDiagram2D<double>\par
>>>
>>>has a class hierarchy that has wrapping gaps.\par
>>>
>>>The class hierarchy wrapping is as follows:\par
>>>
>>>Not wrapped:
>>>
> 
> itk::Mesh<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,float,d
> 
>>>ouble)>)>\par
>>>
>>>Not wrapped:
>>>
> 
> itk::PointSet<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,flo
> 
>>>at,double)>)>\par
>>>
>>>Wrapped: itk::DataObject\par
>>>
>>>Wrapped: itk::Object\par
>>>
>>>Wrapped: itk::LightObject\par
>>>
>>>Warning itk::VoronoiSegmentationImageFilter<itk::Image<unsigned char,
>>>2>,itk::Image<unsigned char, 2>,itk::Image<unsigned char, 2> >\par
>>>
>>>has a class hierarchy that has wrapping gaps.\par
>>>
>>>The class hierarchy wrapping is as follows:\par
>>>
>>>Not wrapped:
> 
> itk::VoronoiSegmentationImageFilterBase<(itk::Image<(unsigned
> 
>>>char,2)>,itk::Image<(unsigned char,2)>,itk::Image<(unsigned
> 
> char,2)>)>\par
> 
>>>Wrapped: itk::ImageToImageFilter<(itk::Image<(unsigned
>>>char,2)>,itk::Image<(unsigned char,2)>)>\par
>>>
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned char,2)>)>\par
>>>
>>>Wrapped: itk::ProcessObject\par
>>>
>>>Wrapped: itk::Object\par
>>>
>>>Wrapped: itk::LightObject\par
>>>
>>>Error executing c:\\windows\\system32\\cmd.exe.\par
>>>
>>>\par
>>>
>>>ALL_BUILD - 1 error(s), 3 warning(s)\par
>>>
>>>}
>>>
>>>
>>>
>>>So I use the three steps process for this classes to , but it didn't
> 
> work
> 
>>>properly, due parameter or type error. I take the class
>>>wrap_itkVoronoiSegmentationImageFilter.cxx from CVS as example.
>>>
>>>the error code in Microsoft Visual c++:
>>>
>>>{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fswiss\fcharset0
>>>Arial;}}
>>>{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 create
> 
> swig
> 
>>>package ITKAlgorithmsPython\par
>>>init module: itkCurvatureFlowImageFilter\par
>>>init module: itkDemonsRegistrationFilter\par
>>>init module: itkHistogramMatchingImageFilter\par
>>>init module: itkImageRegistrationMethod\par
>>>init module: itkImageToImageMetric\par
>>>init module: itkMeanSquaresImageToImageMetric\par
>>>init module: itkMutualInformationImageToImageMetric\par
>>>init module: itkMultiResolutionImageRegistrationMethod\par
>>>init module: itkNormalizedCorrelationImageToImageMetric\par
>>>init module: itkOtsuThresholdImageCalculator\par
>>>init module: itkMeanReciprocalSquareDifferenceImageToImageMetric\par
>>>init module: itkThresholdSegmentationLevelSetImageFilter\par
>>>init module: itkGeodesicActiveContourLevelSetImageFilter\par
>>>init module: itkShapeDetectionLevelSetImageFilter\par
>>>init module: itkCurvesLevelSetImageFilter\par
>>>init module: itkNarrowBandLevelSetImageFilter\par
>>>init module: itkNarrowBandCurvesLevelSetImageFilter\par
>>>init module: itkMattesMutualInformationImageToImageMetric\par
>>>init module: itkPDEDeformableRegistrationFilter\par
>>>init module: itkRecursiveMultiResolutionPyramidImageFilter\par
>>>init module: itkVoronoiDiagram2D\par
>>>init module: itkVoronoiSegmentationImageFilter\par
>>>init module: itkVoronoiSegmentationImageFilterBase\par
>>>init module: itkWatershedImageFilter\par
>>>Building wrap_itkWatershedImageFilterPython.cxx from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1_bin\\Wrapping\\CSwig\\Algorithms\\wrap_itk
> 
>>>WatershedImageFilterPython.cxx.rule\par
>>>Warning itk::WatershedImageFilter<itk::Image<double, 3> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>itk::ImageToImageFilter<(itk::Image<(double,3)>,itk::Image<(unsigned
>>>long,3)>)>\par
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned long,3)>)>\par
>>>Wrapped: itk::ProcessObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Warning itk::WatershedImageFilter<itk::Image<double, 2> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>itk::ImageToImageFilter<(itk::Image<(double,2)>,itk::Image<(unsigned
>>>long,2)>)>\par
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned long,2)>)>\par
>>>Wrapped: itk::ProcessObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Warning itk::WatershedImageFilter<itk::Image<float, 3> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>itk::ImageToImageFilter<(itk::Image<(float,3)>,itk::Image<(unsigned
>>>long,3)>)>\par
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned long,3)>)>\par
>>>Wrapped: itk::ProcessObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Warning itk::WatershedImageFilter<itk::Image<float, 2> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>itk::ImageToImageFilter<(itk::Image<(float,2)>,itk::Image<(unsigned
>>>long,2)>)>\par
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned long,2)>)>\par
>>>Wrapped: itk::ProcessObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Building wrap_itkVoronoiSegmentationImageFilterPython.cxx from
>>>
> 
> C:\\CVS-1.8\\InsightToolkit-1.8.1_bin\\Wrapping\\CSwig\\Algorithms\\wrap_itk
> 
>>>VoronoiSegmentationImageFilterPython.cxx.rule\par
>>>Warning itk::Mesh<double,2,itk::DefaultDynamicMeshTraits<double, 2, 2,
>>>double, float, double> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>
> 
> itk::PointSet<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,flo
> 
>>>at,double)>)>\par
>>>Wrapped: itk::DataObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Warning itk::VoronoiDiagram2D<double>\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
>>>
> 
> itk::Mesh<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,float,d
> 
>>>ouble)>)>\par
>>>Not wrapped:
>>>
> 
> itk::PointSet<(double,2,itk::DefaultDynamicMeshTraits<(double,2,2,double,flo
> 
>>>at,double)>)>\par
>>>Wrapped: itk::DataObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Warning itk::VoronoiSegmentationImageFilter<itk::Image<unsigned char,
>>>2>,itk::Image<unsigned char, 2>,itk::Image<unsigned char, 2> >\par
>>>has a class hierarchy that has wrapping gaps.\par
>>>The class hierarchy wrapping is as follows:\par
>>>Not wrapped:
> 
> itk::VoronoiSegmentationImageFilterBase<(itk::Image<(unsigned
> 
>>>char,2)>,itk::Image<(unsigned char,2)>,itk::Image<(unsigned
> 
> char,2)>)>\par
> 
>>>Wrapped: itk::ImageToImageFilter<(itk::Image<(unsigned
>>>char,2)>,itk::Image<(unsigned char,2)>)>\par
>>>Wrapped: itk::ImageSource<(itk::Image<(unsigned char,2)>)>\par
>>>Wrapped: itk::ProcessObject\par
>>>Wrapped: itk::Object\par
>>>Wrapped: itk::LightObject\par
>>>Error executing c:\\windows\\system32\\cmd.exe.\par
>>>\par
>>>ALL_BUILD - 1 error(s), 155 warning(s)\par
>>>}
>>>
>>>
>>>Is it realy necesssary adding this classes to wrapping ??? Because it
> 
> seems
> 
>>>to be hierarchy problem. ;-)
>>>
>>>Did I do something wrong??
>>>
>>>Updating my CVS checkout of ITK , but I didn´t see any thing about those
>>>classes.
>>>
>>>Thanks
>>>
>>>Bruno Cassaro
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>----- Original Message ----- 
>>>From: "Luis Ibanez" <luis.ibanez at kitware.com>
>>>To: "Luis Ibanez" <luis.ibanez at kitware.com>
>>>Cc: "Bruno Cassaro" <bcdalava at cenpra.gov.br>; <insight-users at itk.org>
>>>Sent: Wednesday, October 27, 2004 6:43 PM
>>>Subject: Re: [Insight-users] help with wrapping of
>>>itkVoronoiSegmentationImageFilter
>>>
>>>
>>>
>>>
>>>>Bruno,
>>>>
>>>>You will find new examples on how to use the
>>>>VoronoiSegmenationImageFilter in the directory
>>>>
>>>>    Insight/Examples/Segmentation/
>>>>
>>>>
>>>>They are
>>>>
>>>>        VoronoiSegmenationImageFilter.py
>>>>        VoronoiSegmenationImageFilter.tcl
>>>>        VoronoiSegmenationImageFilter.java
>>>>
>>>>
>>>>Please let us know if you find any problems,
>>>>
>>>>
>>>>   Thanks
>>>>
>>>>
>>>>     Luis
>>>>
>>>>
>>>>===========================================
>>>>Luis Ibanez wrote:
>>>>
>>>>
>>>>
>>>>>Hi Bruno,
>>>>>
>>>>>Thanks for pointing this out.
>>>>>
>>>>>We added this issue as Bug # 1292
>>>>>http://www.itk.org/Bug/bug.php?op=show&bugid=1292&pos=0
>>>>>
>>>>>The wrapper for this class is being added as we speak.
>>>>>
>>>>>----------
>>>>>
>>>>>The process for adding a class to the wrapping involves
>>>>>three steps:
>>>>>
>>>>>A) Create a wrap_itkCLASSNAME.cxx file in one of the
>>>>>  directories in
>>>>>
>>>>>    Insight/Wrapping/CSWig
>>>>>
>>>>>  This file will specify the C++ instantiations that
>>>>>  are going to be wrapped into Tcl, Python and Java.
>>>>>
>>>>>
>>>>>B) Edit the master file of that directory. In this
>>>>>  case the file
>>>>>
>>>>>
>>>>>    wrap_ITKAlgorithms.cxx
>>>>>
>>>>>  and add the group of the new instantiations of this
>>>>>  filter.  That's a line like
>>>>>
>>>>>   ITK_WRAP_GROUP(itkVoronoiSegmentationImageFilter),
>>>>>
>>>>>
>>>>>C) Edit the CMakeLists.txt file in the same directory
>>>>>  and add the new wrap_itkCLASSNAME.cxx file to the
>>>>>  list of files in WRAP_SOURCE.
>>>>>
>>>>>
>>>>>We just did this procedure in the CVS repository.
>>>>>Please update your CVS checkout of ITK and rebuild
>>>>>the wrapping.
>>>>>
>>>>>
>>>>>
>>>>>Please let us know if you have further questions,
>>>>>
>>>>>
>>>>>
>>>>>  Thanks
>>>>>
>>>>>
>>>>>
>>>>>     Luis
>>>>>
>>>>>
>>>>>
>>>>>--------------------
>>>>>Bruno Cassaro wrote:
>>>>>
>>>>>
>>>>>
>>>>>>*Hi ITK user's .....*
>>>>>>** *I'm trying to use itkVoronoiSegmentationImageFilter , and use
>>>>>>python for it. But I can't find  the class. When i was looking for it,
>>>>>>i perceive in my cmakelist don't have
>>>>>>itkVoronoiSegmentationImageFilter wrap.*
>>>>>>** *Updating my itk by CVS i note what a have the
>>>>>>itkVoronoiSegmentationImageFilter class in c++, but it didn't be
>>>>>>wrapped in python by cmake how the others classes were. The stretch of
>>>>>>my cmake code ...*
>>>>>>** *# create the ITKAlgorithmsTcl libraries
>>>>>>SET(WRAP_SOURCES
>>>>>>   wrap_itkCurvatureFlowImageFilter
>>>>>>   wrap_itkHistogramMatchingImageFilter
>>>>>>   wrap_itkImageRegistrationMethod
>>>>>>   wrap_itkImageToImageMetric
>>>>>>   wrap_itkMattesMutualInformationImageToImageMetric
>>>>>>   wrap_itkMeanSquaresImageToImageMetric
>>>>>>   wrap_itkMinMaxCurvatureFlowImageFilter
>>>>>>   wrap_itkMutualInformationImageToImageMetric
>>>>>>   wrap_itkMultiResolutionImageRegistrationMethod
>>>>>>   wrap_itkNormalizedCorrelationImageToImageMetric
>>>>>>   wrap_itkOtsuThresholdImageCalculator
>>>>>>   wrap_itkMeanReciprocalSquareDifferenceImageToImageMetric
>>>>>>   wrap_itkRecursiveMultiResolutionPyramidImageFilter
>>>>>>   wrap_itkSimpleFuzzyConnectednessImageFilterBase
>>>>>>   wrap_itkSimpleFuzzyConnectednessScalarImageFilter
>>>>>>   wrap_itkThresholdSegmentationLevelSetImageFilter
>>>>>>   wrap_itkGeodesicActiveContourLevelSetImageFilter
>>>>>>   wrap_itkShapeDetectionLevelSetImageFilter
>>>>>>   wrap_itkCurvesLevelSetImageFilter
>>>>>>   wrap_itkNarrowBandCurvesLevelSetImageFilter
>>>>>>)*
>>>>>>** ** *Can someone help me?*
>>>>>>*how can adjust my cmake to do the itkVoronoiSegmentationImageFilter
>>>>>>in python ??*
>>>>>>
>>>>>>Regards,
>>>>>>Bruno Cassaro
>>>>>>*
>>>>>>*
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>------------------------------------------------------------------------
>>>>
>>>>>>_______________________________________________
>>>>>>Insight-users mailing list
>>>>>>Insight-users at itk.org
>>>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>Insight-users mailing list
>>>>>Insight-users at itk.org
>>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>>
>>
>>
>>
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 






More information about the Insight-users mailing list