Skip to content Skip to sidebar Skip to footer

White Balance (Color Suppression) Formula?

I need help with a little bit of color math.(RGBA) I'm trying to reduce the amount of green on a character, without actually affecting the green background. Green screen for visual

Solution 1:

I am no expert in the matter but:

I do not think your approach work as you intend (from physics side).

The green background is shining on your character which is adding light to the character surface. So you need to remove that (unwanted light). You are turning all greenish pixels to grayish instead and that is WRONG in my opinion. What if your guy has green T-shirt ?

I would approach this like this:

Firstly I hope you got seamless lighting condition on your Scene set otherwise this will never work without proper 3D illumination/scattering analysis which is a huge task and you would need for that also complete 3D model of your scene.

  1. First detect the amount of light scattered to objects position.

    Simply place white paper sheet to approximate position of your person. take the picture. Then you find the image of the sheet compute its average color and compute how much green color is added to white.

    c[i]=c0[i]+c0[i]*m[i]
    
    • c pixel color (average color of sheet)
    • c0 object color (real object color ... white but should be in scale with c which can be a bit tricky without access to scene stage set)
    • m scale (this is what we need)
    • i channel

    This will lead to system of 3 linear equations so compute m from it. This is invariant on background color so it will work for any color ...

    I do not have an image of white sheete from your set so I use the Teeth instead. The problem is that there is too much red-ish color illuminated from the skin/flesh around so I use only blue channel to compensate. This is not accurate but it will do (unless the background illuminate also to another channels)... so for the extracted teeth image average color:

    teeth <- this is the extracted teeth image I used)

    float m[green]=float(avg[green]-avg[blue])/float(avg[blue]);
    
    • c0 is blue channel of average color
    • c is green channel of average color

    All the other channels of m are zero (for this case). Do not forget that m[] is float !!!.

  2. Now just remove the illumination from image

    Following the same equation compute c0 so:

    c0[i]=c[i]/(1.0+m[i])
    
    • c uncorrected image pixel color
    • c0 corrected image pixel color
    • m scale (computed in step #1)
    • i channel (R,G,B)

    Do each channel each pixel... This is the original image c:

    original greenish

    This is the corrected image c0:

    corrected

    This is the substraction of c-c0:

    sub mask

    As you can see some green is taken away also from background but that is alright as the background is illuminated too !!! Also the wrist is more green then it should be but I think that is because it is too far from the teeth I calibrated for and also might be too close to wall ... as this is highly dependent on the object position too (if lighting is not seamless enough) not to mention it is in shade ...


Solution 2:

Thankyou everyone for your thoughts and ideas. Every comment was a spark that led me to, which I think is, the closest to a solution. It does need more work. If you take a closer look at his fist, you can see it break abit. The next step for this is to build in adjustable values to affect the weight of the effects.

enter image description here enter image description here


Post a Comment for "White Balance (Color Suppression) Formula?"