Short answer: temporary low-pass filter in general lighting
Consider the concept of lighting as a temporal sequence of values representing something like a luminous flux incident on a photographed scene. Your ideal situation is that this function is constant, but the second best situation is that it changes as slowly as possible. The low-pass filter changes a function that can change quickly to one that changes more slowly. Thus, the main stages: (1) Calculate the overall lighting function (2) Calculate a new lighting function using a low-pass filter (3) Normalize the original sequence of images to new illumination values.
(1) The easiest way to calculate the lighting function is to add all the brightness values for each pixel in the image. In simple cases, this may even work; you can guess from my tone that there are a number of caveats.
An important issue is that you would prefer to add illumination values not to some color space (such as HSV), but rather to some physical measure of illumination. Returning from color space to actual indoor light requires data that does not have an image, such as the spectral reflectance of each image surface, so this is unlikely. As a proxy for this, you can use only part of the image that has a consistent reflectance. In the sample image, you can use the table surface at the top of the image. Select a geometric area and calculate from it the total number of lighting.
In this regard, if you have areas of the image in which the camera is saturated, you have lost a lot of information, and the overall value of the illumination will not correspond well to physical lighting. Just cut out any such areas (but do it sequentially in all frames).
(2) Calculate the low-pass filter for the lighting function. These transformations are a fundamental part of every signal processing package. I don’t know enough about OpenCV to find out if it has the corresponding function, so you might need another library. There are many different low-pass filters, but they should all give you similar results.
(3) After you get the low frequency time series, you want to use it as a normalization function for general lighting. Calculate the average value of the low-frequency series and divide by it, obtaining a time series with the average value of 1. Now transform each image by multiplying the lighting in the image by the normalization coefficient. All warnings about perfect performance in a physical lighting space, not a color space, apply.
source share