Is it possible to apply chroma keying, meaning to remove a green (or blue...) screen background, using Gimp? (I happen to use Gimp, but I suppose an answer using Photoshop would be just as good, unless it's referencing a specific Photoshop plugin.)
What I mean is the following:
(Note: I don't know how to do it yet, this mockup was made starting from a stock transparent picture.)
If we look at what needs to be done (or approximated as far as possible, see below) it is the following:
Notice how this procedure is not merely adding an alpha channel; it is changing all colors that lie in the same quadrant as the key color itself. Meaning, if the key color is green, all greenish colors need to be substantially modified, in addition to having a suitable alpha channel added:
The reason I posted this question is that all other questions and answers about this topic miss this crucial point.
You can not turn a shade of green into semi-transparent red, and another shade of green into semi-transparent blue, just by fiddling with the magic wand, the color selection tool, or by copying a channel into a mask.
I don't know the theoretical background behind chroma keying and I'm guessing it could be quite hairy. For instance, the color that lies exactly between the key color (green in this case) and its exact opposite (which would be magenta in this case) is a perfect gray (by definition of opposite color.) Do we need to turn that shade of gray into semi-transparent magenta? What if it was an actual gray in the original picture? (Which is actually more likely.)
Given all this undefined behaviour in the problem space itself, I'm sure Adobe Premiere and all the other professional video production tools contain very sophisticated chroma keying algorithms.
Can we even approximate the result of those algorithms using basic image manipulation, as found in Gimp? Or is any such endeavor bound to fail?
Alternatively, is there an open source Gimp plugin or separate program that can perform a good quality chroma keying on pictures?
Edit: Wikipedia's article gives an example of a simple function for green screen: rgb(r,g,b) -> rgba(r, min(g,b), b, A*(r+b)-B*g)
and goes on to explain that modern algorithms can be much more complicated. Even with the simple function, I understand what it's saying, but I would not know how to perform it using simple selections and channel manipulation.