The documentation is as follows:
-clahe widthxheight{%}{+}number-bins{+}clip-limit{!}
contrast limited adaptive histogram equalization. The image is divided into tiles of width and height pixels. Add % to use the percentage of the image's width and height rather than number of pixels for the widthxheight argument.The tile size should be larger than the size of features to be preserved and respects the aspect ratio of the image. Add ! to force an exact tile width and height. number-bins is the number of histogram bins per tile (min 2, max 65536). The number of histogram bins should be smaller than the number of pixels in a single tile. clip-limit is the contrast limit for localised changes in contrast. A clip-limit of 2 to 3 is a good starting place (e.g. -clahe 50x50%+128+3). Very large values will let the histogram equalization do whatever it wants to do, that is result in maximal local contrast. The value 1 will result in the original image. Note if number of bins and the clip-limit are ommitted, they default to 128 and no clipping respectively.
A good reference is https://en.wikipedia.org/wiki/Adaptive_ ... tion#CLAHE
Here are a few examples.
Input Image (440x320 pixels) (source: https://docs.opencv.org/3.1.0/d5/daf/tu ... ation.html)
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office.png)
Global histogram equalization:
Code: Select all
magick office.png -equalize office_equalize.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office_equalize.png)
Contrast Limited Adaptive Histogram Equalization:
1) Variations in Width and Height where image dimensions are exactly divisible by the tile dimensions.
Code: Select all
magick office.png -clahe 220x160+128+3! office_220x160+128+3_exact.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office_220x160+128+3_exact.png)
Code: Select all
magick office.png -clahe 110x80+128+3! office_110x80+128+3_exact.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office_110x80+128+3_exact.png)
Code: Select all
magick office.png -clahe 55x40+128+3! office_55x40+128+3_exact.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office_55x40+128+3_exact.png)
Animation:
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/animation_office.gif)
2) The same image is generated using tile aspect sizes (default) and exact tile sizes (using !) by these commands since the 440x160 is evenly divisible by 220x160 (each is a factor of 2). The 220x220 in aspect mode, converts the tile size to 220x160 in order to preserve aspect ratio of the tile relative to the image's aspect ratio
Code: Select all
magick office.png -clahe 220x160+128+3! office_220x160+128+3_exact.png
magick office.png -clahe 220x160+128+3 office_220x160+128+3_aspect.png
magick office.png -clahe 220x220+128+3 office_220x220+128+3_aspect.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/office_220x160+128+3_exact.png)
3) No variation in virtual-pixel when the tiles completely fill the image with no excess. That is the image is exactly divisible by the tile dimensions. So all images should look identical. 44x32 is 1/10 the size of the image at 440x320.
Code: Select all
magick office.png -virtual-pixel edge -clahe 44x32+128+3! office_44x32+128+3_exact_edge.png
magick office.png -virtual-pixel mirror -clahe 44x32+128+3! office_44x32+128+3_exact_mirror.png
magick office.png -virtual-pixel black -clahe 44x32+128+3! office_44x32+128+3_exact_black.png
magick office.png -virtual-pixel white -clahe 44x32+128+3! office_44x32+128+3_exact_white.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/animation_44x32+128+3_exact.gif)
4) Variation in virtual-pixel method is visible when the image dimensions not exactly divisible by the tile dimensions. The excess pixels plus one full tile around the boundary of the image will be affected. Here the tiles are 42x30 which divides into the image dimensions of 440x320 leaving an excess partial tile of 20 pixels on each side. So the outer 62 pixels left and right and the outer 50 pixels top and bottom will show differences. This is most visible on the right side of the results.
Code: Select all
magick office.png -virtual-pixel edge -clahe 42x30+128+3! office_42x30+128+3_exact_edge.png
magick office.png -virtual-pixel mirror -clahe 42x30+128+3! office_42x30+128+3_exact_mirror.png
magick office.png -virtual-pixel black -clahe 42x30+128+3! office_42x30+128+3_exact_black.png
magick office.png -virtual-pixel white -clahe 42x30+128+3! office_42x30+128+3_exact_white.png
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/animation_42x30+128+3_exact.gif)
5) Color Image: Equalize vs CLAHE (source: https://imagej.net/Enhance_Local_Contrast_(CLAHE))
Code: Select all
magick Photo1b.jpg -equalize Photo1b_equalize.jpg
magick Photo1b.jpg -clahe 387x174+128+3! Photo1b_387x174+128+3_exact.jpg
magick Photo1b.jpg -clahe 258x116+128+3! Photo1b_258x116+128+3_exact.jpg
magick Photo1b.jpg -clahe 129x58+128+3! Photo1b_129x58+128+3_exact.jpg
![Image](http://www.fmwconcepts.com/misc_tests/clahe_docs/animation_photo1b.gif)