Background removal takes an existing image you provide and removes those parts of the image considered to be “background.
Background removal takes an existing image you provide and removes those parts of the image considered to be “background.”
Request payload
Parameters:
init_image
(str, required) - A base64-encoded image whose background should get removed.alpha_matting
(bool; false) - If true, apply matting on the alpha channel.alpha_matting_foreground_threshold
(number in [0, 255]; 240) - Whenalpha_matting
istrue
, mask pixels larger than this value are considered foreground pixels.alpha_matting_background_threshold
(number in [0, 255]; 10) - Whenalpha_matting
istrue
, mask pixels smaller than this value are considered background pixels.alpha_matting_erode_size
(number; 10) - Whenalpha_matting
is true, size of the erosion structure to apply, in pixels.only_mask
(bool; false) - When true, return only a single-channel image containing a foreground-background mask. Foreground pixels have values closer to 255, and background pixels have values closer to 0.post_process_mask
(bool; true) - Whentrue
, apply morphological operations to the mask to smooth it.bgcolor
(list[int]; optional) - When given, replace background pixels with this color in the output image.
Response
image_b64
(str) - Base64-encoded png containing the processed image.removed_for_safety
(bool) - Whentrue
, background removal was not performed becauseinit_image
was found to have violated our terms of service.