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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With