A new patch is available to add a more Python interface to ITK filters in ITK 5:
This auto-generates a procedural, snake_case interface to ITK filters, i.e. anything that inherits from
itk.ProcessObject. Instead of the Object-oriented interface,
median_filter = itk.MedianImageFilter[ImageType, ImageType].New() median_filter.SetInput(input_image) median_filter.SetRadius(radius) median_filter.Update() result = median_filter.GetOutput()
we can just call
result = itk.median_image_filter(input_image, radius=radius)
This leverages the work by Gaetan Lehmann many years ago in the Python wrapping, which was recently updated and improve by @fbudin. Here the filter is implicitly updated and its output is returned if there is a single output, or the indexed outputs are returned as a tuple if there are multiple. The type of the filter is determined by the input_image type. Parameters that could be set on the object with
SetParameterName can be specified with keyword arguments also in snake case, e.g.