So I have an image that has some dark spots, and they look pretty simple so I think I can creaat an luminance map, invert it and then apply it to my image to undo the dark spots. However all I can find is two methods for equalizing: equalize whole image(with histogram) or segment the image in dark meddium and light parts and equalize which you want. The first approach does not help my problem and the second approach also makes the dark objects in the image lighter. I am sure there is an easy way to do this (long ago I saw somebody do it in a presentation), although I havent been able to find it or come up with it yet.
So my question: how would I create a "luminance map" of an image like this:
So I get a map like this:
Which I can apply inversely to get a better image like this:
I understand I will have discretization errors at the corrected spots, but thats much better than the dark spots. I hope someone can help me do this, thanks!
I mainly use Matlab and have some limited python and mathematica knowledge, but a Matlab example would be most useful to me. One way I thought of myself was taking fft2 and nulling the low frequencies, but that would just destroy all contrast, not just the partss I want.
Similar but different SO questions that did not help me:
thresholding an image based on gradient