Measure the edge contrast before you matte or defringe a pale sweater
If a batch job cuts people out of photos and then runs a defringe step, one number is worth computing first: how far the outline of the clothing sits from the backdrop. On one synthetic pale-sweater sample, that number s

If a batch job cuts people out of photos and then runs a defringe step, one number is worth computing first: how far the outline of the clothing sits from the backdrop. On one synthetic pale-sweater sample, that number split five test images into two groups. With the median colour gap between a 3ā8 px inner ring and a 3ā8 px outer ring at 7.6 or 10.6, switching defringe on turned 92.55% and 73.71% of the sweater transparent. At 15.4 and above the sweater interior survived and only the outline moved.
The sample and the runs
The sample is synthetic, not a real photo. The silhouette is borrowed from a CC0 portrait on Wikimedia Commons ("Always smile" by michael m_minimal, not a passport photo). The backdrop is flat RGB(245,245,245) and only the sweater's lightness differs between samples: ĪE76 of about 2 / 5 / 10 / 20 / 40 from the backdrop, or 1.26 / 2.98 / 6.20 / 12.95 / 28.68 in CIEDE2000. "Transparent" below means alpha under 128, counted over the 428,302 sweater pixels.
One Apple-silicon Mac, one run per setup: the Quick AI model, its "remove background fringe" switch (labelled "decontaminate" in the figure) and an edge flood-fill remover, all from ImgIng https://imging.ai/ , plus open-source rembg u2net at default parameters. Defringe is off by default in the tool.
| Nominal ĪE76 | Edge-ring median gap | Quick AI, defringe off | Quick AI, defringe on | Flood-fill remover |
|---|---|---|---|---|
| ā2 | 7.6 | 0.19% | 92.55% | 99.92% |
| ā5 | 10.6 | 0.13% | 73.71% | 99.56% |
| ā10 | 15.4 | 0.06% | 0.92% | 93.33% |
| ā20 | 25.5 | 0.03% | 0.74% | 0.39% |
| ā40 | 45.4 | 0.02% | 0.60% | 0.36% |
The last three columns are the share of the sweater with alpha under 128. The flood-fill column uses default settings; rembg u2net stayed between 0.02% and 0.24% on all five and is left out of the table.
What to look at in the figure: the Flood fill row is blue across the whole sweater at the first two levels and keeps pale patches along the sleeves at the third. The decontaminate row has large blue patches on the torso at the first two levels and a whole sweater from the third. The Quick AI and rembg rows keep the sweater at every level.
The pre-check
This is an illustrative sketch, not the script behind the table. ring and delta_e76 are placeholder helpers.
# sketch: contrast across the outline, measured before defringe
inner = ring(mask, 3, 8, inside=True) # pixels 3-8 px inside the contour
outer = ring(mask, 3, 8, inside=False) # pixels 3-8 px outside it
gap = delta_e76(np.median(lab[inner], 0), np.median(lab[outer], 0))
if gap < 12: # example threshold from this run
print("low edge contrast: skip defringe, check the edge on a blue backdrop")
In the real run the contour came from the Quick AI output (alpha of 128 or more), and only rows from 700 down in the 1200-pixel-tall image were counted, which is the part below the shoulders. A different model's contour would shift the numbers; that was not tested. The ring needs some contour, so the check runs after a rough cutout and before the step that can delete the garment.
The ring values are larger than the samples' nominal ĪE76 (2.02 / 4.90 / 10.03 / 19.99 / 39.95, sweater mean colour against the backdrop). The two numbers measure different things, medians along the outline versus a mean over the whole sweater, and why the ring reads 7.6 where the nominal figure is 2.02 was not investigated. Two guesses, both unchecked: shading near the outline, and the skin-coloured gaps between arm and body that show in the figure falling into the rings.
Where 12 sits, and where it does not help
On these five points a cut-off of 12 falls between 10.6 and 15.4, so it flags exactly the two samples where defringe emptied the sweater. It is an example picked after seeing these numbers, one image, five points, and not a standard.
The same cut-off would not protect against the flood-fill remover. That method still deleted 93.33% of the sweater at a ring gap of 15.4. Reading the table, it kept the sweater only at 25.5 and above, and nothing was sampled between those two. A guess, unverified: this remover only deletes backdrop-coloured pixels connected to the frame, and the sweater runs off the bottom edge, so near the backdrop colour it is part of the same connected area. Different tools may need different cut-offs.
Interior damage and outline damage are separate. At ĪEā10, Quick AI with defringe on left the interior alone, yet the 10,097 sweater pixels within 8 px of the reference outline went from 2.58% to 38.61% transparent.
Practice and assumptions
Assumption, not run: a batch pipeline could store the ring gap next to each image and send low values to manual review instead of auto-defringing. Assumption: for a pale garment on a pale backdrop, checking one cutout on a coloured backdrop costs less than finding a hollow sweater after export.
Scope
Everything above rests on one person, one sweater and one backdrop colour, with lightness as the only variable. Hue differences, a plain white shirt, other backdrops, brush retouching and edge shrink were not tested, and no third-party tool was measured. Read the ring values as readings from this image, not as a rule for white clothing.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes ā full credit and traffic to the original publisher.