Adaptive Gamma Correction with Weighting Distribution 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 first which is about adaptive gamma correction with weighting distribution [1] in PHP using \Imagick.


  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. The adjustment parameter has been set to 0.5.

1original 1.agagcwd [1] 2original 2.agagcwd [1] 3original 3.agagcwd [1] 4original 4.agagcwd [1]
5original 5.agagcwd [1] 6original 6.agagcwd [1] 7original 7.agagcwd [1] 8original 8.agagcwd [1]
9original 9.agagcwd [1] 10original 10.agagcwd [1] 11original 11.agagcwd [1] 12original 12.agagcwd [1]
13original 13.agagcwd [1] 14original 14.agagcwd [1] 16original 16.agagcwd [1] 17original 17.agagcwd [1]


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


Overall I believe that the agcwd (always assuming that I did implement it properly) is doing a good job. However, it is happily amplifying noise/distortions. So probably one should denoise the picture before using this method. Also playing around with the adjustment parameter (using a different one for dark and bright images) should help to reduce this effect.


  1. 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