Correct image for local dark / light spots, equalise luminance / intensity (local in location, not by dark/medium/light areas)
Asked Answered
A

1

3

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:

lena spotted

So I get a map like this:

lena luminance

Which I can apply inversely to get a better image like this:

lena lekker

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:

Image equalisation

thresholding an image based on gradient

Histogram of image

Matlab - Local Histogram Equalization

How to find out light, medium and dark color?

Abjuration answered 26/9, 2013 at 18:25 Comment(1)
I found a similar question with very nice answers here: #17914574Abjuration
I
1

You will have to very precisely model the nature of the dark spots for this process to work. Can you characterize whether the dark gradient is linear, exponential, power, trigonometric, or some other predictable function? Is it always exactly circular?

Having straight-line elements in the photo helps, and may provide a source of samples to calculate the nature of the dark spot from. If you treat the dark spot like a quadratic or cubic function in three dimensions (X, Y, luminance) then you can solve it based on a certain number of known points.

Immoral answered 26/9, 2013 at 18:31 Comment(3)
Well lets start with linear and exactly circular or a straight gradient, that would already improve my image much. There arent straight lines, but the are continuous structures that should have approximately the same intensity inside and outside the spots.Abjuration
ok, so imagine your photo is a 3d heightmap. in this depiction, a linear circular gradient is a cone, and a linear straight gradient is a constant slope. pick out some consistent features in the image, and mark how they change in the spots. the difference in where those marks are (lower in 3d space than they should be, if dark=low) and where they should be will provide sample points on the surface of the cone or slope that you are trying to calculate. A slope (plane) can be calculated with three points on its surface. I think a cone takes four, but I could be misremembering.Immoral
Ah now I understand why the precise model of my dark spots is so important. Thanks this is a helpful answer. If no better answers come I will accept it.Abjuration

© 2022 - 2024 — McMap. All rights reserved.