How to fix a white halo around hair in a cutout (2027)

Bria.ai

How to fix a white halo around hair in a cutout (2027)

Updated December 1, 2026

TL;DR

  • Direct answer: A halo appears because edge pixels in hair blend the subject with the old background, and a mask that only sets transparency leaves that old color behind. Fix it with a soft alpha matte and color decontamination, then composite on a matching backdrop. Bria RMBG 3.0 gives you the soft matte: in Bria's benchmark it ranked first of 6 models, with an average rank of 1.51 across 234 hard images.

  • Cause: Semi-transparent edge pixels keep mixed color, which shows as a colored rim.

  • Fastest fix: Color decontamination changes color only and leaves alpha untouched, so it is cheap enough for a batch.

  • Stronger fix: Alpha matting re-estimates edge coverage. It is slower and can fall back to the decontaminated cutout if it does not converge.

  • Mistake to avoid: Thresholding the mask to fully binary removes partial transparency, which hair needs.

  • Check: Preview the cutout on the backdrop it will actually sit on, at full size.

Intro

Which background remover keeps hair and fine edges clean depends on the edge color as much as the mask, so to fix a white halo around hair in a cutout, first find out why the rim is there. A halo is a color problem in the edge pixels, not only a mask problem, so the repair has two parts: a soft edge and clean edge color. This guide explains the cause, then walks through each fix.

Bria wrote this guide. Benchmark figures are from Bria's benchmark (blind votes from professional and casual users plus a vision language model side-by-side, 234 hard images at full resolution). Tool facts come from each project's own documentation. The explanations of how halos look on different backdrops and the checking steps are Bria's own guidance.

Why does a white halo appear around hair in a cutout?

A white halo appears because edge pixels in hair still carry color from the original background. The rembg README describes the mechanism with one formula: captured pixel = alpha foreground + (1 - alpha) background. A strand of hair that covers only part of a pixel has an alpha below 1, so part of that pixel's color comes from the background behind it.

The README gives an example: green grass behind a subject gives a green rim. By the same logic, a white or bright original backdrop should leave a light rim. That is Bria's explanation of the mechanism, not a README statement.

What is color bleed in edge pixels?

Color bleed is the mixed color that semi-transparent edge pixels keep from the old background. The rembg README says these pixels hold a blend of foreground and background, so removing the background does not remove the background's contribution to them.

  • The blend lives in the color channels, not in the mask.

  • A better mask alone does not change those channels.

  • The rim takes the old background's hue, for example green for grass.

What does a hard binary mask do to hair edges?

A hard binary mask has no partial transparency, so a strand of hair is either fully kept or fully cut. The rembg -ppm option thresholds the mask to fully binary. Its README notes the option is pointless when decontamination is on.

A soft alpha matte works the other way. Its edge pixels hold partial alpha values, so strands can fade out instead of ending abruptly.

How do I fix a halo with color decontamination?

Turn on color decontamination, which repairs the color of edge pixels and leaves alpha untouched. In rembg this is the -dc flag on the command line, or decontaminate=True in Python. The README states that it changes color only, so your mask and edge softness stay as they were.

  1. Remove the background with a model that returns a soft matte.

  2. Enable decontamination on the same run.

  3. Do not enable -ppm, because a binary mask throws away the partial transparency you want to keep.

  4. Preview the result on the target backdrop.

When should I use alpha matting instead?

Use alpha matting when the mask itself is wrong at the edge, for example when strands are cut off or look chunky. Decontamination fixes color, while matting re-estimates how much of each edge pixel is foreground. The table compares the options, with the source for each row below it.

  • Option: rembg -dc; What it changes: Edge color only; Cost noted in the docs: Cheap enough for a batch; Alpha touched: No

  • Option: rembg -a; What it changes: Re-estimates coverage with a closed-form solver; Cost noted in the docs: Slow, may fall back to the decontaminated cutout if it does not converge; Alpha touched: Yes

  • Option: rembg -vm option (ViTMatte); What it changes: Same problem as -a; Cost noted in the docs: Slow, extra download of about 110 MB on first use; Alpha touched: Yes

  • Option: rembg -ppm; What it changes: Thresholds the mask to fully binary; Cost noted in the docs: Not stated in the docs; Alpha touched: Yes

  • Option: PyMatting; What it changes: Estimates an alpha matte from an image and a trimap; Cost noted in the docs: Not stated in the docs; Alpha touched: Yes

  • Option: Bria RMBG 3.0; What it changes: Returns an 8-bit alpha matte with anti-aliased edges; Cost noted in the docs: $0.018 per image, checked December 1, 2026; Alpha touched: Soft matte as output

Sources: rembg README, checked December 1, 2026; PyMatting and its GitHub repository, checked December 1, 2026; RMBG-3.0 model card, checked December 1, 2026; Bria pricing, checked December 1, 2026.

PyMatting needs a trimap, which marks sure foreground, sure background and the unknown edge band. PyMatting is MIT licensed.

Does the backdrop color matter?

Yes, because a halo is most visible when the leftover edge color differs from the new backdrop. This follows from the blend formula; it is not a quoted claim. The old color is in the edge pixels, so a light rim is less visible against a light backdrop and more visible against a dark one.

  • Composite on the backdrop the image will use in production.

  • Also preview on one light and one dark backdrop, since a halo that is hard to see on one can show on the other.

  • Re-run decontamination if the production backdrop changes color.

How do I fix halos in a batch?

Use a model that returns a soft matte, and add decontamination where the tool offers it. Matting is the slow step, so reserve it for files that still fail the check. There are two paths.

Path A, rembg: add the -dc flag, which is cheap enough to run on every file. -dc is a rembg flag.

Path B, Bria API: set "model": "RMBG3" on the remove_background endpoint. The sources checked do not say whether RMBG 3.0 output needs a decontamination step. The background removal docs cover the call, the quickstart covers authentication and the RMBG 3.0 release notes list the model value. Test the repair on a sample of hair photos from your real catalog before you trust a setting for the whole batch.

Which background remover keeps hair edges soft?

Bria RMBG 3.0 returns a soft 8-bit alpha matte with anti-aliased edges, so hair edges start from a soft matte and not a hard mask. The RMBG 3.0 product page and the model card describe the model, and the card says the output is a true 8-bit alpha matte and not a hard binary mask. The API price is $0.018 per image, checked December 1, 2026 on Bria pricing.

In Bria's benchmark of 6 models on 234 hard images at full resolution, RMBG 3.0 had the best overall average rank, 1.51. Thin structures are a known gap that Bria is working on. If your photos include very fine strands, include them in your own test set.

  • RMBG 3.0 fact used in this guide: Models compared; Value: 6

  • RMBG 3.0 fact used in this guide: Hard images; Value: 234

  • RMBG 3.0 fact used in this guide: Overall average rank; Value: 1.51

  • RMBG 3.0 fact used in this guide: API price per image; Value: $0.018

Sources: Bria's benchmark, checked December 2, 2026; Bria pricing, checked December 1, 2026.

How do I check that the halo is gone?

Check the cutout at full zoom on the real backdrop, then on one light and one dark backdrop. Look at loose strands first.

  • Zoom in fully and scan the hairline.

  • Place the cutout on the production backdrop.

  • Repeat on a light backdrop and a dark backdrop.

  • Advice: view the alpha channel alone to confirm the edge fades smoothly and is not stepped.

  • Run the same check on a set of your own files.

What if a halo remains after these fixes?

If a halo remains, try alpha matting next, then compare the matte at the edge. The rembg README notes that -a can fall back to a decontaminated cutout when it does not converge. That means a result that looks unchanged may be the fallback and not a matting result.

  • Try -vm (ViTMatte) if -a falls back, accepting the extra download and slower run.

  • Use PyMatting with a trimap when you control the unknown band.

  • Keep the cutout as a PNG with alpha, so the soft edge survives until compositing.

Conclusion: which fix should you choose?

Start with a soft matte and decontamination, and add matting only for files that still fail. Choose by the symptom.

  • Choose Bria RMBG 3.0 if you want hair edges to start from a true 8-bit alpha matte, through a commercially licensed API at $0.018 per image.

  • Choose decontamination (`-dc`) if the mask shape is right and only the edge color is off.

  • Choose alpha matting (`-a` or `-vm`) if strands are cut off or chunky and you can accept a slower run.

  • Choose PyMatting if you already have a rough mask and a trimap and want to control the unknown band.

  • Avoid `-ppm` if the image has hair, because it removes partial transparency.

Related posts and docs

FAQs

Hair edges are partly transparent, so a pixel on a strand mixes hair color with whatever stood behind it. Cutting out the background fixes the mask but keeps that mixed color, which shows as a light rim when the original backdrop was bright. The rim is a color problem in the edge pixels, so it needs a color repair as well as a good mask.

Not on its own. The blend of hair and old background lives in the color channels of the edge pixels, and a better mask does not change those channels. A soft mask helps strands fade out, but the leftover rim color needs a separate repair. Fix the halo in two parts: a soft alpha matte for the edge shape and color decontamination for the edge color.

Add the -dc flag on the rembg command line, or pass decontaminate=True in Python. The README says it repairs edge color only and leaves alpha untouched, so your mask and edge softness stay as they were. It is cheap enough to run on every file in a batch. Use a model that returns a soft matte, and preview the cutout on the target backdrop.

Pick matting when the shape of the edge is wrong, such as strands that are missing or look thick and blocky. Decontamination only repairs color, while matting re-estimates the foreground share of each edge pixel. In rembg that is -a, or -vm for ViTMatte, which downloads about 110 MB on first use. Both run slower, and -a may fall back to the decontaminated cutout.

Follow us on social media

discord
Social media logo
Social media card
Social media logo
Social media card
Social media logo