The APLT technique works depending where is the peak of the histogram (in fact, it assume that distribution is unimodal). If the peak of your image histogram is located at h_{max}, you must choice your gamma value to obtain a maximum slope of the transformation function (your formula 11) at the histogram peak. In your formula, you only detect the maximum range of a window, so it's not the same concept. Perhaps, you could choose a better d function (your eq 13).
Your information is very small, in your file my APLT.tif, it seems that the gamma value is shifted to the very bright zones, so in that case, you obtain a good contrast only in bright zones of the image.