# To perform histogram equilization in ITK

**URL:** <https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358>\
**Category:** Algorithms\
**Created:** [October 28, 2019, 8:30am UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358 "2019-10-28T08:30:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EE18D504\_SINDHURA\_C](https://discourse.itk.org/letter_avatar_proxy/v4/letter/e/b3f665/32.png) [@EE18D504\_SINDHURA\_C](https://discourse.itk.org/u/EE18D504_SINDHURA_C)\
**Post date:** [October 28, 2019, 8:30am UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358/1 "2019-10-28T08:30:18Z")

</div>

Is there any code or example to perform histogram equilization in itk or simple itk?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [October 28, 2019, 1:36pm UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358/2 "2019-10-28T13:36:17Z")

</div>

Yes, there is. First [Google result](https://www.google.com/search?q=itk+histogram+equalization) is this [example](https://itk.org/ITKExamples/src/Filtering/ImageStatistics/AdaptiveHistogramEqualizationImageFilter/Documentation.html). There is also [HistogramMatchingImageFilter](https://itk.org/Doxygen/html/classitk_1_1HistogramMatchingImageFilter.html).

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [October 28, 2019, 1:46pm UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358/3 "2019-10-28T13:46:42Z")

</div>

Hello @EE18D504_SINDHURA_C,

Unfortunately, ITK does not have the classical histogram equalization (the example pointed to by @dzenanz is a variant but does not provide settings equivalent to the classical filter). As a consequence SimpleITK does not have the classical histogram equalization.

Having said that, you can easily roll your own in Python as shown in [this SimpleITK Jupyter notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/70_Data_Augmentation.ipynb). The function name there is not surprisingly `histogram_equalization`.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [October 28, 2019, 2:00pm UTC](https://discourse.itk.org/t/to-perform-histogram-equilization-in-itk/2358/4 "2019-10-28T14:00:06Z")

</div>

New in the ITK v5.1 development branch is the [`SetReferenceHistorgram`](https://itk.org/Doxygen/html/classitk_1_1HistogramMatchingImageFilter.html#a6e4eb1282821bb0e46f9cd59a3057449) method. When provided an equal level reference histogram, this will perform the classical histogram equalization algorithm.
