Localized Gamma Correction Question:

Is there an algorithm that does (what I would call) "localized" gamma correction? 

That is, applying different gamma corrections on different parts of an image, using a masking filter or something along those lines.

I have two images that seem to be correlated by a mix of exposure and gamma corrections, but not equally on the whole image:

First image



Second image



For further details on how these images were created, please refer to this (unanswered) earlier post.
Gamma Correction is Pixel Wise operation.
Hence what you can do is estimate it per pixel and then average it per local area.