I took a screenshot of a character from a game I'm playing, with a mod that adds blocks for chroma keying. What I'm stuck on is that even though the image has no shadows (fullbright enabled for the screenshot), using the color tool will always leave too much of my background in place, or remove parts of the subject. I want to remove every pixel with certain color values from the image, without removing anything except those pixels. Is there a better way to do this than the color tool?
1 Answer
The color and fuzzy selection tools are both "binary": pixels are either fully selected or not selected at all. At the same time the pixels at the edge of things are a blend of the two colors (subject and background), so they aren't exactly the same color as the background. When you use that to remove a background you end up with either pixellated edges (threshold too high) or a halo of the initial background (threshold too low).
What you really want is replace the background color by transparency, and make pixels of intermediate colors partially transparent.
The right tool for this is Colors>Color to alpha. To avoid applying C2A to areas inside the subject that could have a color close the background one, a good technique is to:
- Fuzzy-select the background with a normal threshold.
Select>Grow
the selection so that it includes the edge pixels. 1px is sufficient if the image is clean (no JPG artifacts) but iusing 2-3px should be OK.Colors>Color to alpha
and remove the background color
Add an alpha-channel to the layer first if it hasn't got one already.
-
Well, since this is a game with no lighting effects applied, the background is completely consistent. (Well, not quite, there's a slight difference between the foreground tiles the subject stands on and the background, but both are completely solid colors.) I just need to remove all pixels with certain specific color values. I'll try the solution you posted when I get home, but this isn't like a photograph where transparency and color blending at the edges vary wildly.– chexo3Jan 17, 2019 at 18:49
-
On the contrary, I use this technique on CGI (logos, text, etc....). It's not really for photos (even thought it also works for this sometimes).– xenoidJan 17, 2019 at 19:07
-
I tried it. It still removes part of the subject. I think I need to take a new screenshot without anti aliasing, at a lower resolution. Let me try that screenshot and see if I have better luck. Also, color to alpha is grayed out, even though I should have an alpha channel.– chexo3Jan 17, 2019 at 21:52
-
If C2A is greyed out then you didn't use it? In 2.10 it is disabled if there is no alpha channel on the layer (
Layer>Transparency>Add alpha channel
to add one). On 2.8 and 2.10 it can also be disabled if your picture is color-indexed (Image>Mode>RGB
to handle that).– xenoidJan 17, 2019 at 22:37 -
So, everything's working now. By enabling "Save an uncompressed copy" in Steam, I was able to get an uncompressed PNG screenshot. No more JPG artifacts. Though I eventually got your technique to work on a JPG. Either way, I was able to make the background tiles I took the screen shot in front of completely black, so there was no way to tell them apart from the foreground tiles the subject was standing on. Then I could use fuzzy select, or Select by Color. Then I could just delete the selection. As long as I remembered to add an alpha channel. Thanks for your help!– chexo3Jan 18, 2019 at 14:10