I know this is ancient, but I'm browsing and I put answers where the next person can find them.
The ClipLimit parameter adjusts the degree to which the local histogram is flattened. The parameter is given in the range of [0 1], but internally, this is denormalized in a way that is quite instructive. To avoid posting Matlab product code, this code is from the MIMT implementation instead (which shares the same syntax and behavior):
% denormalize the cliplimit
% clim_norm=1 results in AHE without contrast limiting (highest output contrast)
% clim_norm=clim_min results in maximal contrast limiting (lowest output contrast)
tilepxcount=prod(tilesize); % number of pixels per tile
clim_min=ceil(tilepxcount/numbins); % lowest contrast is when hgram is totally flat
clim=clim_min+round(clim_norm*(tilepxcount-clim_min)); % simple denormalization
This parameter is then used per-tile when leveling each local histogram. That part of the code basically works like this:
- Find the total amount of excess pixel counts among histogram bins with counts>clim
- Redistribute those counts to the bins which have room to spare in an iterative process.
The function clipHistogram() and the rest of adapthisteq() has decent comments compared to a lot of functions. With the exception of the interpolator, everything is visible to anyone wanting to understand the code. There are some minor differences between adapthisteq and the MIMT version linked above, so maybe it would be of help to see the same thing written slightly different (for better or worse).