CLAHE - Redistributing excess pixels among histogram bins

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
-Elia
Posts: 2
Joined: 2015-03-15T06:43:12-07:00
Authentication code: 6789

CLAHE - Redistributing excess pixels among histogram bins

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CLAHE - Redistributing excess pixels among histogram bins

Post 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
snibgo's IM pages: im.snibgo.com
-Elia
Posts: 2
Joined: 2015-03-15T06:43:12-07:00
Authentication code: 6789

Re: CLAHE - Redistributing excess pixels among histogram bins

Post 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.
Post Reply