{"course":{"slug":"image-editing","title":"Editing an Image","url":"https://addaly.com/learn/image-editing","level":"beginner","track":"create"},"lesson":{"slug":"matting-fringes-and-colour-spill","title":"Three equations, seven unknowns: why hair is hard","url":"https://addaly.com/learn/image-editing/matting-fringes-and-colour-spill","position":27,"of":78,"minutes":9,"answer":"A boundary pixel is a mixture of foreground and background whose separation is mathematically underdetermined, so every extraction needs extra information, and the edge colour must be recomputed rather than contracted, feathered or contrasted away.","keyIdea":"A boundary pixel is a mixture of foreground and background whose separation is mathematically underdetermined, so every extraction needs extra information, and the edge colour must be recomputed rather than contracted, feathered or contrasted away."},"body":{"format":"markdown","text":"## The compositing equation\n\nEvery pixel in a photograph where subject meets background obeys one relationship:\n\n```\nI = α·F + (1 − α)·B\n```\n\n`I` is what the camera recorded. `F` is the foreground's true colour at that pixel, `B` is the background's true colour, and `α` is what fraction of the pixel the foreground covers.\n\nThat is three equations, one per colour channel, and seven unknowns: three for `F`, three for `B`, and `α`. The system is underdetermined. There is no correct answer derivable from the pixel alone; there are infinitely many combinations of foreground, background and coverage that produce the same recorded value.\n\nThis is not a software limitation. It is why extracting hair is hard, why every tool needs extra information from you, and why the answer is always an estimate.\n\n## How the extra information is supplied\n\n**A trimap.** You mark three regions: definitely foreground, definitely background, and unknown. The algorithm now has known `F` values nearby and known `B` values nearby, and only has to solve for `α` in the unknown band. This is exactly what the **Refine Edge brush** in Select and Mask is doing when you scrub over the hair: you are drawing the unknown region of a trimap.\n\n**A known background.** Shoot against a uniform colour and `B` is known everywhere, which collapses the problem. That is chroma key, and it is why studios use it.\n\n**A learned prior.** Deep matting models estimate `α` from the image using patterns learned from thousands of hand-made mattes. Better than the classical methods on hair and confidently wrong on anything unusual.\n\n## Colour spill, and why contracting does not fix it\n\nNow the second half of the problem. The equation says a partial pixel's recorded colour `I` is a mixture that **includes the background**. Extract the alpha correctly and place the subject on white, and those partial pixels still carry the old background's colour in their `F`.\n\nAgainst a green wall, hair edges are green. Against a red curtain, they are pink. Against a grey studio wall, they are grey, which is the familiar dull halo.\n\nThree things people try, and why each fails:\n\n- **Contracting the selection** by a pixel. This does not remove contamination; it removes the hair. Fine strands are only two or three pixels wide, so contracting deletes them entirely, and you get the helmet.\n- **Feathering.** This blends the contaminated pixels further into the surroundings, spreading the problem over a wider band.\n- **Raising the mask contrast.** This turns partial pixels into fully-on or fully-off ones, which removes the softness that made the edge believable.\n\nThe only fix that addresses the cause is **colour decontamination**: recomputing the `F` of each partial pixel from the nearby known foreground colour, while keeping its `α`. In Photoshop this is the *Decontaminate Colours* checkbox in Select and Mask, and it outputs to a new layer because it rewrites pixel colours. In video compositing it is called **spill suppression** and every keyer has one.\n\n> Figure: A green fringe on hair: three things that fail, and what addresses the cause. Does not work: Contracting by a pixel: strands are two or three pixels wide, so you delete them and get the helmet; Feathering: spreads the contaminated pixels across a wider band; Raising the mask contrast: turns partial pixels fully on or off and removes the softness that made the edge believable. Works: Decontaminate Colours: rewrites each partial pixel's colour from nearby known foreground and keeps its alpha; In GIMP: a layer clipped to the cut-out, set to Colour mode, painted along the fringe at 30 to 50 per cent; At capture: a neutral grey wall, subject two metres clear of it, lit separately, so there is little spill to remove. The alpha is correct. The colour underneath it is wrong, because the recorded value of a partial pixel is a mixture that includes the old background. Only recomputing that colour treats the cause; everything on the left treats the symptom and costs you the hair.\n\nThe free route: GIMP does not have an automatic decontaminator, and the manual equivalent works. Create a new layer clipped to the cut-out, set it to **Colour** blend mode, sample the subject's correct colour near the edge, and paint along the contaminated fringe at 30 to 50 per cent opacity. You are replacing the hue while keeping the luminosity and the alpha. It takes two minutes on a portrait and it works.\n\nA second manual trick for green spill specifically: a Hue/Saturation layer targeting Greens, saturation down, masked to the edge band. Crude, fast, and adequate for a marketplace listing.\n\n## Shooting to make this easy\n\nThe cheapest fix happens before the shutter.\n\n- **Shoot against a background close in tone and neutral in colour** to what the subject will end up on. Grey or white for a product going on white. Contamination from a neutral background is far less visible than from a coloured one.\n- **Separate the subject from the background** by two metres if you can, and light them separately. This reduces the coloured light bouncing off the background onto the subject, which is spill that no decontamination can fully remove because it is real light that landed on the hair.\n- **Green screen is for video, not stills.** Video needs it because frame-by-frame manual work is impossible. For a single still, a plain grey wall plus ten minutes of masking gives a better result with no spill problem.\n\n## Checking the result\n\nThe test that catches everything: put the cut-out on three backgrounds in turn: white, mid-grey, and a saturated colour that contrasts with the original background. The saturated one is where contamination screams. If the hair reads as clean on all three, it is clean.\n\nThen look at the edge at 100 per cent against the darkest of them. A pale rim you did not see on white will be obvious on black.\n\n## What remains unsolvable\n\nSome pixels have no answer. If the subject is motion-blurred against a background, the mixing happened over time as well as space, and the equation's `F` is itself a blur of several different foreground colours. If the background behind the hair is itself detailed and high contrast (a bookshelf, foliage) then the contaminating colour varies pixel to pixel and decontamination has no consistent value to replace it with.\n\nIn those cases the honest answer is that the shot cannot be cut out cleanly, and the choices are to keep some of the original background as a soft vignette, to reshoot, or to tell the client. Spending three hours on a shot that was not extractable is a mistake most people make once."},"check":{"question":"A subject shot against a green wall is cut out with a technically accurate alpha channel and placed on white. The hair shows a green fringe. The editor contracts the mask by one pixel, and the fringe reduces but the fine strands vanish. What does this demonstrate?","options":[{"text":"Contracting removes the partial pixels entirely, and those pixels are the hair, so the contamination and the detail are the same pixels and cannot be separated by erosion.","correct":true},{"text":"The alpha channel was inaccurate after all, and a better matting model would produce an edge with no contamination.","correct":false,"tempting":"Conflates coverage with colour: a perfect alpha still leaves partial pixels carrying mixed colour, which is a property of the capture rather than of the mask."},{"text":"Green is the channel with the highest luminance weight, so green contamination is uniquely resistant to erosion in a way other colours are not.","correct":false,"tempting":"Borrows a true fact about perceived brightness and applies it where it has no bearing: erosion removes pixels regardless of their hue."},{"text":"The mask needed feathering rather than contracting, which would blend the green into the white background and make it invisible.","correct":false,"tempting":"Proposes the second of the three standard failed fixes: feathering spreads contaminated colour across a wider band rather than replacing it."}]},"prev":{"slug":"segmentation-models-and-one-click-cutouts","title":"What the one-click button is actually doing","url":"https://addaly.com/learn/image-editing/segmentation-models-and-one-click-cutouts"},"next":{"slug":"hair-fur-glass-and-smoke","title":"The four subjects that are not opaque","url":"https://addaly.com/learn/image-editing/hair-fur-glass-and-smoke"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Three equations, seven unknowns: why hair is hard', in Editing an Image. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/image-editing/matting-fringes-and-colour-spill (Accessed: 13 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Three equations, seven unknowns: why hair is hard","courseTitle":"Editing an Image","module":{"index":3,"slug":"selections-cutouts-and-edges","title":"Selections, cut-outs and edges"},"answer":null,"keyIdea":"A boundary pixel is a mixture of foreground and background whose separation is mathematically underdetermined, so every extraction needs extra information, and the edge colour must be recomputed rather than contracted, feathered or contrasted away.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"left":{"title":"Does not work","items":["Contracting by a pixel: strands are two or three pixels wide, so you delete them and get the helmet","Feathering: spreads the contaminated pixels across a wider band","Raising the mask contrast: turns partial pixels fully on or off and removes the softness that made the edge believable"]},"type":"compare","right":{"title":"Works","items":["Decontaminate Colours: rewrites each partial pixel’s colour from nearby known foreground and keeps its alpha","In GIMP: a layer clipped to the cut-out, set to Colour mode, painted along the fringe at 30 to 50 per cent","At capture: a neutral grey wall, subject two metres clear of it, lit separately, so there is little spill to remove"]},"title":"A green fringe on hair: three things that fail, and what addresses the cause","caption":"The alpha is correct. The colour underneath it is wrong, because the recorded value of a partial pixel is a mixture that includes the old background. Only recomputing that colour treats the cause; everything on the left treats the symptom and costs you the hair."},"alt":"Figure: A green fringe on hair: three things that fail, and what addresses the cause. Does not work: Contracting by a pixel: strands are two or three pixels wide, so you delete them and get the helmet; Feathering: spreads the contaminated pixels across a wider band; Raising the mask contrast: turns partial pixels fully on or off and removes the softness that made the edge believable. Works: Decontaminate Colours: rewrites each partial pixel’s colour from nearby known foreground and keeps its alpha; In GIMP: a layer clipped to the cut-out, set to Colour mode, painted along the fringe at 30 to 50 per cent; At capture: a neutral grey wall, subject two metres clear of it, lit separately, so there is little spill to remove. The alpha is correct. The colour underneath it is wrong, because the recorded value of a partial pixel is a mixture that includes the old background. Only recomputing that colour treats the cause; everything on the left treats the symptom and costs you the hair."}},"blocks":[{"t":"h2","id":"the-compositing-equation","runs":[{"text":"The compositing equation"}]},{"t":"p","runs":[{"text":"Every pixel in a photograph where subject meets background obeys one relationship:"}]},{"t":"code","lang":"","label":"Text","text":"I = α·F + (1 − α)·B"},{"t":"p","runs":[{"text":"I","code":true},{"text":" is what the camera recorded. "},{"text":"F","code":true},{"text":" is the foreground’s true colour at that pixel, "},{"text":"B","code":true},{"text":" is the background’s true colour, and "},{"text":"α","code":true},{"text":" is what fraction of the pixel the foreground covers."}]},{"t":"p","runs":[{"text":"That is three equations, one per colour channel, and seven unknowns: three for "},{"text":"F","code":true},{"text":", three for "},{"text":"B","code":true},{"text":", and "},{"text":"α","code":true},{"text":". The system is underdetermined. There is no correct answer derivable from the pixel alone; there are infinitely many combinations of foreground, background and coverage that produce the same recorded value."}]},{"t":"p","runs":[{"text":"This is not a software limitation. It is why extracting hair is hard, why every tool needs extra information from you, and why the answer is always an estimate."}]},{"t":"h2","id":"how-the-extra-information-is-supplied","runs":[{"text":"How the extra information is supplied"}]},{"t":"p","runs":[{"text":"A trimap.","b":true},{"text":" You mark three regions: definitely foreground, definitely background, and unknown. The algorithm now has known "},{"text":"F","code":true},{"text":" values nearby and known "},{"text":"B","code":true},{"text":" values nearby, and only has to solve for "},{"text":"α","code":true},{"text":" in the unknown band. This is exactly what the "},{"text":"Refine Edge brush","b":true},{"text":" in Select and Mask is doing when you scrub over the hair: you are drawing the unknown region of a trimap."}]},{"t":"p","runs":[{"text":"A known background.","b":true},{"text":" Shoot against a uniform colour and "},{"text":"B","code":true},{"text":" is known everywhere, which collapses the problem. That is chroma key, and it is why studios use it."}]},{"t":"p","runs":[{"text":"A learned prior.","b":true},{"text":" Deep matting models estimate "},{"text":"α","code":true},{"text":" from the image using patterns learned from thousands of hand-made mattes. Better than the classical methods on hair and confidently wrong on anything unusual."}]},{"t":"h2","id":"colour-spill-and-why-contracting-does-not-fix-it","runs":[{"text":"Colour spill, and why contracting does not fix it"}]},{"t":"p","runs":[{"text":"Now the second half of the problem. The equation says a partial pixel’s recorded colour "},{"text":"I","code":true},{"text":" is a mixture that "},{"text":"includes the background","b":true},{"text":". Extract the alpha correctly and place the subject on white, and those partial pixels still carry the old background’s colour in their "},{"text":"F","code":true},{"text":"."}]},{"t":"p","runs":[{"text":"Against a green wall, hair edges are green. Against a red curtain, they are pink. Against a grey studio wall, they are grey, which is the familiar dull halo."}]},{"t":"p","runs":[{"text":"Three things people try, and why each fails:"}]},{"t":"ul","items":[[{"text":"Contracting the selection","b":true},{"text":" by a pixel. This does not remove contamination; it removes the hair. Fine strands are only two or three pixels wide, so contracting deletes them entirely, and you get the helmet."}],[{"text":"Feathering.","b":true},{"text":" This blends the contaminated pixels further into the surroundings, spreading the problem over a wider band."}],[{"text":"Raising the mask contrast.","b":true},{"text":" This turns partial pixels into fully-on or fully-off ones, which removes the softness that made the edge believable."}]]},{"t":"p","runs":[{"text":"The only fix that addresses the cause is "},{"text":"colour decontamination","b":true},{"text":": recomputing the "},{"text":"F","code":true},{"text":" of each partial pixel from the nearby known foreground colour, while keeping its "},{"text":"α","code":true},{"text":". In Photoshop this is the "},{"text":"Decontaminate Colours","i":true},{"text":" checkbox in Select and Mask, and it outputs to a new layer because it rewrites pixel colours. In video compositing it is called "},{"text":"spill suppression","b":true},{"text":" and every keyer has one."}]},{"t":"p","runs":[{"text":"The free route: GIMP does not have an automatic decontaminator, and the manual equivalent works. Create a new layer clipped to the cut-out, set it to "},{"text":"Colour","b":true},{"text":" blend mode, sample the subject’s correct colour near the edge, and paint along the contaminated fringe at 30 to 50 per cent opacity. You are replacing the hue while keeping the luminosity and the alpha. It takes two minutes on a portrait and it works."}]},{"t":"p","runs":[{"text":"A second manual trick for green spill specifically: a Hue/Saturation layer targeting Greens, saturation down, masked to the edge band. Crude, fast, and adequate for a marketplace listing."}]},{"t":"h2","id":"shooting-to-make-this-easy","runs":[{"text":"Shooting to make this easy"}]},{"t":"p","runs":[{"text":"The cheapest fix happens before the shutter."}]},{"t":"ul","items":[[{"text":"Shoot against a background close in tone and neutral in colour","b":true},{"text":" to what the subject will end up on. Grey or white for a product going on white. Contamination from a neutral background is far less visible than from a coloured one."}],[{"text":"Separate the subject from the background","b":true},{"text":" by two metres if you can, and light them separately. This reduces the coloured light bouncing off the background onto the subject, which is spill that no decontamination can fully remove because it is real light that landed on the hair."}],[{"text":"Green screen is for video, not stills.","b":true},{"text":" Video needs it because frame-by-frame manual work is impossible. For a single still, a plain grey wall plus ten minutes of masking gives a better result with no spill problem."}]]},{"t":"h2","id":"checking-the-result","runs":[{"text":"Checking the result"}]},{"t":"p","runs":[{"text":"The test that catches everything: put the cut-out on three backgrounds in turn: white, mid-grey, and a saturated colour that contrasts with the original background. The saturated one is where contamination screams. If the hair reads as clean on all three, it is clean."}]},{"t":"p","runs":[{"text":"Then look at the edge at 100 per cent against the darkest of them. A pale rim you did not see on white will be obvious on black."}]},{"t":"h2","id":"what-remains-unsolvable","runs":[{"text":"What remains unsolvable"}]},{"t":"p","runs":[{"text":"Some pixels have no answer. If the subject is motion-blurred against a background, the mixing happened over time as well as space, and the equation’s "},{"text":"F","code":true},{"text":" is itself a blur of several different foreground colours. If the background behind the hair is itself detailed and high contrast (a bookshelf, foliage) then the contaminating colour varies pixel to pixel and decontamination has no consistent value to replace it with."}]},{"t":"p","runs":[{"text":"In those cases the honest answer is that the shot cannot be cut out cleanly, and the choices are to keep some of the original background as a soft vignette, to reshoot, or to tell the client. Spending three hours on a shot that was not extractable is a mistake most people make once."}]}],"check":{"question":[{"text":"A subject shot against a green wall is cut out with a technically accurate alpha channel and placed on white. The hair shows a green fringe. The editor contracts the mask by one pixel, and the fringe reduces but the fine strands vanish. What does this demonstrate?"}],"options":[{"text":[{"text":"Contracting removes the partial pixels entirely, and those pixels are the hair, so the contamination and the detail are the same pixels and cannot be separated by erosion."}],"correct":true,"tempting":null},{"text":[{"text":"The alpha channel was inaccurate after all, and a better matting model would produce an edge with no contamination."}],"correct":false,"tempting":[{"text":"Conflates coverage with colour: a perfect alpha still leaves partial pixels carrying mixed colour, which is a property of the capture rather than of the mask."}]},{"text":[{"text":"Green is the channel with the highest luminance weight, so green contamination is uniquely resistant to erosion in a way other colours are not."}],"correct":false,"tempting":[{"text":"Borrows a true fact about perceived brightness and applies it where it has no bearing: erosion removes pixels regardless of their hue."}]},{"text":[{"text":"The mask needed feathering rather than contracting, which would blend the green into the white background and make it invisible."}],"correct":false,"tempting":[{"text":"Proposes the second of the three standard failed fixes: feathering spreads contaminated colour across a wider band rather than replacing it."}]}],"order":[1,0,2,3],"why":null},"prev":{"slug":"segmentation-models-and-one-click-cutouts","title":"What the one-click button is actually doing","minutes":9},"next":{"slug":"hair-fur-glass-and-smoke","title":"The four subjects that are not opaque","minutes":9}}}