Color Distance, Flood Fill, and Edge Feathering Explained
How color-key background removal decides which pixels to clear, how connected-region filling protects the subject, and how feathering builds a soft alpha edge.
Primary Browser Tool
Transparent Background Maker
Turn a solid or near-solid background color transparent with tolerance and edge feathering, ideal for logos, signatures, and product shots.
Measuring How Similar Two Colors Are
Each pixel has red, green, and blue values from 0 to 255, which can be treated as coordinates in a cube. The difference between two colors is then the straight-line distance between two points: the square root of the sum of the squared differences in each channel. Identical colors have distance 0. Black and white, at opposite corners, are about 441.7 apart, the largest distance possible.
Tolerance is expressed as a percentage of that maximum. At 10 percent, any pixel within about 44 units of the chosen color is treated as background. This plain RGB distance is fast and predictable. It does not match human perception exactly, since the eye is more sensitive to some differences than others, but for separating a flat background from a distinct subject it is entirely adequate.
From Distance to Transparency
A hard cutoff would produce jagged edges, because the pixels along the boundary of any anti-aliased shape are blends of subject and background. Edge Feather adds a second, wider threshold. Pixels inside the tolerance become fully transparent. Pixels beyond tolerance plus feather remain fully opaque. Pixels between the two keep a fraction of their opacity proportional to how far across the band they lie.
| Distance from chosen color | Resulting opacity |
|---|---|
| 0 up to the tolerance | 0% (fully removed) |
| One quarter of the way across the feather band | 25% |
| Halfway across the feather band | 50% |
| Beyond the feather band | 100% (untouched) |
Connected Regions: The Flood Fill
Color alone cannot distinguish the white of a background from the white of a shirt or the highlight on a product. “Connected only” adds a spatial rule: a pixel is cleared only if it can be reached from the border of the image through an unbroken path of background-colored pixels.
The fill starts from every border pixel that matches and spreads to neighbors above, below, left, and right. It spreads only through pixels that are fully within the tolerance. Pixels in the feather band are cleared when reached but do not pass the fill onward. This detail prevents a soft, partly matching edge from acting as a bridge that lets the fill leak into a similar color inside the subject.
When Connectivity Is the Wrong Rule
Enclosed background areas, such as the inside of the letter O, the gap between a handle and a mug, or the spaces in a line drawing, are not connected to the border. Connected mode leaves them filled. “Everywhere” drops the spatial rule and clears every matching pixel, which is correct for logos and drawings and risky for photos with light-colored subjects.
Practical Examples
White mug on a white backdrop
In “Everywhere” mode the mug’s highlights become holes. In “Connected only” mode the backdrop is cleared up to the mug’s darker outline and the highlights inside remain opaque.
Common Mistakes & Honest Limitations
Mistakes to Avoid
- Expecting tolerance to behave the same for all colors. Removing a mid-gray background needs care, because many shadow and highlight tones lie within a short distance of gray.
Technical Limitations
- Feathered pixels keep their original color, which contains some of the old background. Removing that tint, known as color decontamination, is not performed.