[ITK] Python wrapper for first order ITKTextureFeatures

Matt McCormick matt.mccormick at kitware.com
Sun Sep 17 14:48:52 EDT 2017


Dear Yannick,

It looks like you are close.

To find out what template parameters to pass, the class declaration
has this information:

  https://github.com/InsightSoftwareConsortium/ITKTextureFeatures/blob/master/include/itkFirstOrderTextureFeaturesImageFilter.h#L51

template< class TInputImage, class TOutputImage, class TKernel >

There are three template parameters, the input image, the output
image, and the kernel. To see what kind of types are used for these
parameters, the test gives a hint:

https://github.com/InsightSoftwareConsortium/ITKTextureFeatures/blob/master/test/itkFirstOrderTextureFeaturesImageFilterTest.cxx#L28-L30

The KernelType is usually itk::FlatStructuringElement< ImageDimension
>. A grep through ITK's sources finds an example of how this is used
as a template parameter when wrapping:

  https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/BinaryMathematicalMorphology/wrapping/itkBinaryDilateImageFilter.wrap


There is also a good wrapping reference in the ITK Software Guide to reach for:

  https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html#x48-1540009.5


Please let use know if more help is needed. Contribution pull requests
are welcome and appreciated :-)


Thanks,
Matt

On Sat, Sep 16, 2017 at 12:45 PM,  <yannick.suter at istb.unibe.ch> wrote:
> Dear all,
>
> I would like to use the the first order texture features of
> ITKTextureFeatures
> (https://github.com/InsightSoftwareConsortium/ITKTextureFeatures) in Python.
> Thanks to J.Vimort et al. for the great work!
> Since the coocurrence and run length features are already wrapped, I tried
> to take these as an example and wrap it myself (I'm very new to this).
>
> I would appreciate any help to point me into the right direction.
>
> That's what I've tried:
> - Created a .wrap file "itkFirstOrderTextureFeaturesImageFilter.wrap" and
> put it in the "/Modules/External/ITKTextureFeatures/wrapping" directory (see
> below)
> - Added "itkFirstOrderTextureFeaturesImageFilter" to the CMakeLists.txt in
> the "/Modules/External/ITKTextureFeatures/wrapping" directory, now looking
> like this:
>
> itk_wrap_module(TextureFeatures)
>
> set(WRAPPER_SUBMODULE_ORDER
>    itkCoocurrenceTextureFeaturesImageFilter
>    itkRunLengthTextureFeaturesImageFilter
>    itkFirstOrderTextureFeaturesImageFilter)
>
> itk_auto_load_submodules()
> itk_end_wrap_module()
>
> This gives me the folowwing error for every datatype I set to wrap:
>>>
>>> /home/yannick/Projects/PhD/ITK/ITK/bin/Wrapping/itkFirstOrderTextureFeaturesImageFilter.cxx:79:18:
>>> error: too few template arguments for class template
>>> 'FirstOrderTextureFeaturesImageFilter'
>>>    typedef itk::FirstOrderTextureFeaturesImageFilter< itk::Image< signed
>>> short,2 >, itk::Image<itk::Vector<float,8>,2> >
>>> itkFirstOrderTextureFeaturesImageFilterISS2IVF82;
>                  ^
>>>/home/yannick/Projects/PhD/ITK/ITK/Modules/External/ITKTextureFeatures/include/itkFirstOrderTextureFeaturesImageFilter.h:52:27:
>>> note: template is declared here
>>>class ITK_TEMPLATE_EXPORT FirstOrderTextureFeaturesImageFilter:
>
> Since the it's working if I use it in C++, I don't see where template
> arguments are missing.
>
> Best and thank you,
>
> Yannick
>
> That's my .wrap-file:
> ------------
> set(OutputVectorDim 8)
> itk_wrap_class("itk::FixedArray")
>   itk_wrap_template("${ITKM_F}${OutputVectorDim}"
> "${ITKT_F},${OutputVectorDim}")
> itk_end_wrap_class()
>
> itk_wrap_class("itk::Vector")
>   itk_wrap_template("${ITKM_F}${OutputVectorDim}"
> "${ITKT_F},${OutputVectorDim}")
> itk_end_wrap_class()
>
> WRAP_TYPE("itk::Image" "I" "itkImage.h")
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     ADD_TEMPLATE("V${ITKM_F}${OutputVectorDim}${d}"
> "itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}")
>   endforeach()
> END_WRAP_TYPE()
>
> itk_wrap_class("itk::Image" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     itk_wrap_template("V${ITKM_F}${OutputVectorDim}${d}"
> "itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}")
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_class("itk::ImageSource" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     itk_wrap_template("IV${ITKM_F}${OutputVectorDim}${d}"
> "itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_class("itk::ImageToImageFilter" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     foreach(t ${WRAP_ITK_INT})
>       itk_wrap_template("${ITKM_I${t}${d}}IV${ITKM_F}${OutputVectorDim}${d}"
>                         "${ITKT_I${t}${d}},
> itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>     endforeach()
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_simple_class("itk::ImageIOBase" )
>
> itk_wrap_class("itk::ImageFileReader" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     itk_wrap_template("IV${ITKM_F}${OutputVectorDim}${d}"
>
> "itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_class("itk::ImageFileWriter" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     itk_wrap_template("IV${ITKM_F}${OutputVectorDim}${d}"
>
> "itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_class("itk::ImageFileWriter" POINTER)
>   foreach(d ${ITK_WRAP_IMAGE_DIMS})
>     itk_wrap_template("IV${ITKM_F}${OutputVectorDim}${d}"
>
> "itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>   endforeach()
> itk_end_wrap_class()
>
> itk_wrap_class("itk::FirstOrderTextureFeaturesImageFilter" POINTER)
> foreach(d ${ITK_WRAP_IMAGE_DIMS})
>   foreach(t ${WRAP_ITK_INT})
>     itk_wrap_template("${ITKM_I${t}${d}}IV${ITKM_F}${OutputVectorDim}${d}"
>                       "${ITKT_I${t}${d}},
> itk::Image<itk::Vector<${ITKT_F},${OutputVectorDim}>,${d}>")
>     itk_wrap_template("${ITKM_I${t}${d}}${ITKM_VI${ITKM_F}${d}}"
>                       "${ITKT_I${t}${d}}, ${ITKT_VI${ITKM_F}${d}}")
>   endforeach()
> endforeach()
> itk_end_wrap_class()
>
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>


More information about the Community mailing list