As in the title, I am searching for an algorithm to produce the effect used in Sin City film, which is selecting a color from an image and desaturating the rest of it.
In theory, it should be simple enough:
- Convert each pixel to HSL.
- If the hue is within a given range, then increase the saturation by a certain amount.
- Otherwise, set the saturation to 0.
- Convert the HSL value back to RGB and go on to the next pixel.
You would need to experiment to figure out how big a hue range you needed, and how much to increase the saturation.
This probably wouldn't give you perfect results. Even if the input scene already had the guy in green and everything else in decidedly not-green colors (which you couldn't count on unless you had purposely staged it that way), you would probably get some less-than-ideal results around the boundaries between "green guy" and "background". Given the sort of budgets movies have to work with, I suspect they did a lot of manual touch-up where needed. But you can get close and try to tweak from there.Joe White2012-04-14 11:41:59
Convert image to HSV space and set saturation to zero for all hues except the one you want to keep.2012-04-14 11:44:12