Rough edges, halos, or color fringing can sometimes appear around a subject after background removal, especially around hair, fur, or transparent objects. These artifacts are usually caused by low contrast, compression, or challenging backgrounds. The tips below can help improve edge quality.
Quick takeaway: Use high-quality images, crop toward square, and enable despill in the API to reduce halos and color bleed.
Use the API despill option
When using the BackgroundErase API, enabling the despill option helps remove background color bleeding along edges. This is especially useful when the original background has strong colors (for example, green or blue).
- Reduces color halos around hair and fine edges.
- Improves visual quality when compositing onto new backgrounds.
- Recommended for production use.
Tip: Set despill=true in your API request when edge quality is important.
Prefer square or near-square crops
As with overall accuracy, edge quality improves when images are closer to a square aspect ratio. Extreme aspect ratios can reduce the effective resolution around edges.
- Crop wide or tall images when possible.
- Keep the subject large and centered in the frame.
Avoid heavy compression
Compression artifacts can confuse the model around edges, leading to jagged cutouts or halos.
- Use lossless formats (PNG, TIFF, lossless WebP) for best edge quality.
- If using JPG, ensure high quality and avoid repeated re-encoding.
Increase foreground–background contrast
Halos are more likely when the foreground and background share similar colors or textures.
- Use solid or contrasting backgrounds when possible.
- Good lighting helps define clean edges.
Start with high-resolution images
Fine edge detail requires sufficient pixel density.
- Use Full Resolution downloads for final compositing.
- Avoid upscaling low-quality inputs.
Summary
- Enable despill=true in the API.
- Crop toward square aspect ratios.
- Use lossless formats whenever possible.
- Ensure strong contrast and good lighting.
