Remove Background
Action
RemoveBackground
Introduction
This interface is mainly used to remove the background and can also be used to obtain the mask of the main object.
Request
Parameter Name | Type | Description | Required |
---|---|---|---|
Action | String | The corresponding API instruction name | ✓ |
PublicKey | String | User's public key, which can be obtained from the PICPIK User Center (opens in a new tab) | ✓ |
Signature | String | User's signature generated based on the public key and API instruction, see Signature for details | ✓ |
request_uuid | String | Request UUID, randomly generated by using the UUID generation method. This parameter can be utilized to manage the requests of your business and clients. |
Parameter Name | Type | Description | Required |
---|---|---|---|
RawImage | String | The raw image encoded in Base64 needs to remove the background. | ✓ |
Box | []int | The main object's boundary is defined by four coordinates: top left x, top left y, bottom right x, and bottom right y. | |
ErodeSize | Int | Blurred pixels (0~40) on the edge, default: 15 | |
ForegroundThreshold | Int | Foreground threshold (0~255), default: 240 | |
BackgroundThreshold | Int | Background threshold (0~255), default: 15 | |
HairOptimization | String | Hair optimization. Available values: auto, on, off. Default: auto | |
OnlyMask | Bool | Whether returns mask only, default: false |
Request Example
{
"Action": "RemoveBackground",
"PublicKey": "ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
"Signature": "2e3ded4d95337e8e0e76c05f056ff958eb98f062",
"request_uuid": "15ba36f2-2d69-40bd-9e0c-3e73f0f5acd0",
"Box": [
180,
264,
510,
642
],
"ErodeSize": 15,
"ForegroundThreshold": 240,
"BackgroundThreshold": 15,
"HairOptimization": "auto",
"OnlyMask": false,
"RawImage": "data:image/jpeg;base64,xxx"
}
Response
Field Name | Type | Description | Required |
---|---|---|---|
RetCode | Int | Return status code: 0 indicates a successful return, while non-zero indicates a failure | ✓ |
Action | String | Instruction name | ✓ |
Message | String | The error message is returned when RetCode is non-zero, providing a detailed description | |
request_uuid | String | Returns the UUID that was included in the request |
Parameter Name | Type | Description | Required |
---|---|---|---|
TaskUID | String | Task UID, used to query task details and get results | ✓ |
Response Example
{
"Action": "RemoveBackground",
"RetCode": 0,
"Message": "",
"request_uuid": "8482d350-04f9-421b-817b-1d98b3a4dcfa",
"TaskUID": "cktlm6lrh4xxx8ng9nf0"
}