AttributeError: module 'itk' has no attribute 'AdaptiveHistogramEqualizationImageFilter'

I have install through pip ITK 5.2 into an anaconda virtual environment running python 3.8. I am trying to use the AdaptiveHistogramEqualizationImageFilter in my python code and I am getting the following error:

AttributeError: module ‘itk’ has no attribute ‘AdaptiveHistogramEqualizationImageFilter’. I can successfully use other filters from ITK but just not this one?

from typing import List, Tuple
import numpy as np
import itk

def adjust_image_contrast(img_arrays:List[np.ndarray], shift_scale: float,
                          shift: int) -> List[np.ndarray]:
    processed_arrays = []
    for img_array in img_arrays:
        img = itk.GetImageFromArray(img_array)
        img_type = type(img)

        # Use an IntensityWindowingImageFilter to "brighten up the data"
        # This would be optional for anyone running the overall workflow
        # filter1 = itk.ShiftScaleImageFilter[img_type, img_type].New()
        # filter1.SetScale(shift_scale)
        # filter1.SetShift(shift)
        filter1 = itk.AdaptiveHistogramEqualizationImageFilter.New()
        filter1.setAlpha(0.3)
        filter1.setBeta(0.3)
        filter1.setRadius(10)

        filter1.SetInput(img)
        filter1.Update()

        processed_arrays.append(itk.GetArrayFromImage(filter1.GetOutput()))

    return processed_arrays

Anyone have the I’m sure very simple fix?

Thanks
Mike Jackson

The use of that filter from Python was disabled for reasons that I don’t fully understand. I will try to figure out what’s up with that.

The Python was disabled due to some incompatibilities with third-party code. Preliminary testing on my part shows that those incompatibilities are no longer an issue. I am going to put it through the full test suite and if all is still looking good, we can re-enable the Python versions.

A fix for this is looking feasible. Please see ITK Pull Request 2667 to track the progress.

1 Like