Adaptive Gamma Correction for Brightness-Distorted Images with \Imagick and PHP

I’m currently looking for a way to auto-gamma-correct / enhance my photos. In the end I wrote implementations for some papers – Here’s the second which might be understood as followup to the AGCWD from my previous Post. The paper’s title is » Contrast Enhancement of Brightness-Distorted Images by Improved Adaptive Gamma Correction « [1] and it basically enhances the AGCWD [2].

I refer to the implementation of [1] as IAGCWD in the following.


  1. Transformation results
  2. Implementation
  3. Opinion
  4. References

Transformation results

All photos (these are photos I’ve taken) have been scaled and cropped to 1600x1200px and converted to PNG. I’m just using the experimental settings from the paper (α = 0.75 for dimmed, α = 0.25 for bright, Tt = 112, rt = 0.3, r = 0.5) [1]. I’ve only picked pictures which indeed fall into the categories bright or dimmed according to the given paper [1]; remaining pictures won’t be processed by this technique, hence not shown here.

1original 1.agagcwd [2] 1.agiagcwd [1] 3original 3.agagcwd [2] 3.agiagcwd [1]
4original 4.agagcwd [2] 4.agiagcwd [1] 6original 6.agagcwd [2] 6.agiagcwd [1]
7original 7.agagcwd [2] 7.agiagcwd [1] 10original 10.agagcwd [2] 10.agiagcwd [1]
12original 12.agagcwd [2] 12.agiagcwd [1] 13original 13.agagcwd [2] 13.agiagcwd [1]
15original 15.agagcwd [2] 15.agiagcwd [1] 16original 16.agagcwd [2] 16.agiagcwd [1]
17original 17.agagcwd [2] 17.agiagcwd [1] 18original 18.agagcwd [2] 18.agiagcwd [1]


The implementation is available under MIT license written in PHP using \Imagick at Github


Personally, except for a very few cases I almost always prefer the plain AGCWD. The implementation here just darkens the pictures too much and for bright pictures it also adds too much contrast. I tried a lower value for the adjustment parameter (0.1) which works better – still the resulting images are too dark. Again: Always assuming that I properly implemented the paper. The only picture which I do indeed like with this implementation is the satellite dish – you can see how the contrast is enhanced on the trees.


  1. IAGCWD:
    Cao, Gang & Huang, Lihui & Tian, Huawei & Huang, Xianglin & Wang, Yongbin & Zhi, Ruicong. (2017). Contrast Enhancement of Brightness-Distorted Images by Improved Adaptive Gamma Correction. CAEE. 10.1016/j.compeleceng.2017.09.012.
  2. AGCWD:
    S. Huang, F. Cheng and Y. Chiu, „Efficient Contrast Enhancement Using Adaptive Gamma Correction With Weighting Distribution,“ in IEEE Transactions on Image Processing, vol. 22, no. 3, pp. 1032-1041, March 2013. doi: 10.1109/TIP.2012.2226047

No Comments

Post a Comment