I am working on a project which involves me inserting an image into a background image but not just normally. I need the Image which needs to be inserted to match the contrast and brightness levels of the background image. For example : Test Image 1 with Logo inserted
Test Image 2 with Logo inserted
Any help on how I can do this?
CodePudding user response:
Compute the average intensity of the initial image, as well as its standard deviation, and repeat for the darker image. Now you will apply the following linear rule to the pixel values:
v' = σ'.(v - µ)/σ µ' = σ'/σ.v (µ' - σ'.µ/σ).
The exact correspondence between these coefficients and the contrast/brightness settings depend on how your software defines these.
CodePudding user response:
First I would suggest you to find the dominant color of your ROI. By using
Colorthief library. This will give the RGB color space of your bg. Then convert it to the LAB color space using skimage skimage.color.rgb2lab(rgb[, illuminant, ...])
. I belive this will help you!