I'm working on perfecting a green screen algorithm and noticed I was getting a very pronounced dark edge around objects in some scenarios. When trying to figure out what was causing it, I noticed my algorithm was not at fault - the dark outline actually exists in the source images (the background is an actual green screen, there is no material editing involved in the source image at all), look at the subject's nose and lip here:

enter image description here

And at the edge of her face here:

enter image description here

If you look closely, it's not hard to see that the dark outline is in the source images. Is this some kind of natural effect of light? A flaw in the camera? An effect of image compression? Do we perhaps see such effects with our own eyes and just not realize it?


3 Answers 3


To me it looks like the kind of halo you get in USM sharpening. Note that you get a light outline next to the hair in the second photo.

If those images with the background are camera-produced jpegs, there's not much you can do to remove them. If you have the raw files, test without sharpening and do any required sharpening after removal of the green background (or after final compositing)


No, your algorithm is at fault. Here is a blow-up of a small area of your second example:

You are not properly handling when the foreground subject is partially blended against the green background. Ideally, the original image is point-sampled. Each pixel would then represent either just the green background or just the foreground. Your input images aren't like that, and your algorithm doesn't handle it well.

The best way to deal with this is to start with pictures that are much higher resolution than what you ultimately want. That approximates the point-sampled case more, and any blended transition region will be a smaller fraction of the overall picture dimension.

Proper blue or green screen algorithms do try to deal with this case, although it gets tricky and you can always concoct cases that can fool it. Put another way, the algorithm has to essentially guess about information that is not there.

One way is to do special edge processing. In the transition region between solid foreground and solid background, you have to include some additional logic. At that transition region, you assume that any hue change from the foreground in the direction of the background hue is partial blending with the background, and then remove it. Again, this can be tricky, and it can be fooled, but most of the time it will yield more of what you think it should. Even relatively simple logic will fix the case I show above. Other cases may never be fixed to your satisfaction.

Again, the better answer is to start with a high-res original.

  • " Each pixel would then represent either just the green background or just the foreground." Are you suggesting the alpha should be all or nothing? I assume I misunderstood you.
    – J.Todd
    Mar 18, 2018 at 17:23
  • The same exact dark edge you're talking about exists in the source image. I dont get what you mean. It's an algorithm meant to capture shadows, anything significantly different from the chroma key should by design to some extent remain opaque. So it doesnt appear to be a flaw, if that dark edge exists in the source image. And it does.
    – J.Todd
    Mar 18, 2018 at 17:40
  • @Viz: As I said, the statement you quoted applied to a point-sampled image. This has nothing to do with alpha. Mar 18, 2018 at 20:44
  • I'd rather suspect your algorithm too, look for the strong green inside smaller gap in the hair in first one and green stain on jaw bone on the second one.
    – user174174
    Mar 19, 2018 at 1:24

It might be the camera pixel-averaging artifact, as an image from the sensor is usually postprocessed, for example to remove physical sensor pixelation or boost sharpness.

Besides each sensor pixel averages light by default, as it has non-zero size. E.g. on edges some green is mixed with the skin color in those pixels.

Also sensor thickness adds to the effect by slight light pollution from nearby pixels.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.