[itk-python] BlockMatchingImageFilter usage problem

Hello everyone, I am trying to use BlockMatchingImageFilter to do block matching.
I refered to the c++ example match feature points (https://itk.org/Doxygen/html/SphinxExamples_2src_2Registration_2Common_2MatchFeaturePoints_2Code_8cxx-example.html#_a1) and wrote the following codes,

Dimension = 2
CoordType = itk.F
PointSetType = itk.PointSet[CoordType, Dimension]

pointSet = PointSetType.New()
points = pointSet.GetPoints()

# Create points
point = itk.Point[CoordType,Dimension]()
point[0] = 40
point[1] = 65
points.InsertElement(0, point)

# read images 
PixelType = itk.F
n = 200
path_tr = '../training'
name = '_2CH_ES'
sample = 'patient'+str(n).zfill(4)+'/patient'+str(n).zfill(4)+name+'.mhd'
img_es = itk.imread(os.path.join(path_tr,sample),PixelType)

name = '_2CH_ED'
sample = 'patient'+str(n).zfill(4)+'/patient'+str(n).zfill(4)+name+'.mhd'
img_ed = itk.imread(os.path.join(path_tr,sample),PixelType)

ImageType = itk.Image[PixelType,3]

# block matching 
block_filter = itk.BlockMatchingImageFilter[ImageType].New()


I got an error : in method ‘itkBlockMatchingImageFilterIF3_SetFeaturePoints’, argument 2 of type ‘itkPointSetMD33STMD3333FFMD33 const *’. Does anyone know how to make the pointset type to be MD33STMD3333FFMD33??

Thank you for your help!!!

Did you try itk.D? doubles are more commonly used for everything else except pixel type.

Hello! Thank you for your reply!
Yes, I have tried the itk.D and i still got the same error.
I used help() function to check the type of arguments in Blockmatchingfilter and i got:

Help on itkBlockMatchingImageFilterIF3 in module itkBlockMatchingImageFilterPython object:
class itkBlockMatchingImageFilterIF3(itkBlockMatchingImageFilterIF3_Superclass)
| Computes displacements of given points from a fixed image in a
| floating image.
| …
| …
| …
| SetFeaturePoints = itkBlockMatchingImageFilterIF3_SetFeaturePoints(…)
| itkBlockMatchingImageFilterIF3_SetFeaturePoints(itkBlockMatchingImageFilterIF3 self, itkPointSetMD33STMD3333FFMD33 _arg)
| SetFixedImage = itkBlockMatchingImageFilterIF3_SetFixedImage(…)
| itkBlockMatchingImageFilterIF3_SetFixedImage(itkBlockMatchingImageFilterIF3 self, itkImageF3 _arg)
| SetMovingImage = itkBlockMatchingImageFilterIF3_SetMovingImage(…)
| itkBlockMatchingImageFilterIF3_SetMovingImage(itkBlockMatchingImageFilterIF3 self, itkImageF3 _arg)
| …

I know that itkBlockMatchingImageFilterIF3 should be an image object of float type and with dimension 3, but i am totally lost by the definition of itkPointSetMD33STMD3333FFMD33.
Do you have any idea what does it mean? How could i define the pointset object?
( In the c++ example, the pointset object was defined as following

using PointSetType = BlockMatchingImageFilterType::FeaturePointsType;
using PointType = PointSetType::PointType;
using PointsContainerPointer = PointSetType::PointsContainerPointer;
PointSetType::Pointer pointSet = PointSetType::New();
PointsContainerPointer points = pointSet->GetPoints();

Thank you very much!

I got the type of pointset needed in this filter

itk::PointSet<itk::Matrix<double, 3u, 3u>, 3u, itk::DefaultStaticMeshTraits<itk::Matrix<double, 3u, 3u>3u, 3u, float, float, itk::Matrix<double, 3u, 3u> > >

This is quite complicated…

I remember there was a problem with wrapping mesh traits, but I don’t know whether that has been fixed meanwhile. @matt.mccormick is BlockMatchingImageFilter's wrapping supposed to work?

These classes squeaked past the mesh simplification of ITK 5.0 – I’ll see if we can improve on that.

These feature points are meant to be generated by the itk.MaskFeaturePointSelectionFilter as described in the corresponding article.

1 Like

This was addressed here: