Page 1 of 1

CLAHE - Redistributing excess pixels among histogram bins

Posted: 2015-03-15T06:45:49-07:00
by -Elia
In order to clip an image's histogram to a maximum value, according to the CLAHE algorithm, the excess pixels (above the clip limit) will be distributed equally among all the histogram bins (While keeping track none of the bins exceed the max limit of course).

Now, when working with (8,8) region size and distributing 13 pixels on 256 bins, the uniform added value (13/256) will be rounded to zero and so the total number of pixels in histogram will be reduced from (8,8) -> 64px to 64 - 13 = 51px.

That doesn't make sense since I'll be neglecting 13 pixels of the region.

Any tips on how to tackle this part of the algorithm?

Reference article of the algorithm (Pages 365-366):
http://www.cs.unc.edu/Research/MIDAG/pu ... ations.pdf

Re: CLAHE - Redistributing excess pixels among histogram bins

Posted: 2015-03-15T10:53:33-07:00
by snibgo
Thanks for the link.

The question is: does it matter much that the count is reduced by 13? I doubt that it does, but I've never tried with such small images, where there are more buckets than pixels. If it bothers you, you could add one to some buckets and zero to others, so the count remains the same.

Or you could store counts as floating-point numbers so the question doesn't arise. If 13 pixels are to be redistributed among 256 buckets, each count will increase by 13/256 = 0.0508. This seems the obvious solution.

In my implementation of CLAHE, bucket counts are integers, and the total count across all the buckets varies with each iteration. See http://im.snibgo.com/eqlimit.htm

Re: CLAHE - Redistributing excess pixels among histogram bins

Posted: 2015-03-17T06:38:08-07:00
by -Elia
Thank you for sharing your implementation.
I've decided, in the case of more buckets than pixels, to distribute the one pixel to some buckets and others zero.
In the example of 13 pixels excess pixels, then 256 / 13 = 19.7 ~ 19, so one pixels will be added on every 19th bucket.