Image Analysis - Segment

Analyze the input image. The request either contains an image stream with any content type ['image/*', 'application/octet-stream'], or a JSON payload which includes a url property to be used to retrieve the image stream. An image stream of content type 'image/png' is returned, where the pixel values depend on the analysis mode. The returned image has the same dimensions as the input image for modes: foregroundMatting. The returned image has the same aspect ratio and same dimensions as the input image up to a limit of 16 megapixels for modes: backgroundRemoval.

POST /imageanalysis:segment?api-version=2023-02-01-preview
POST /imageanalysis:segment?mode={mode}&api-version=2023-02-01-preview

URI Parameters

Name In Required Type Description
api-version
query True

string

Requested API version.

mode
query

SegmentationModeApiModel

The analysis mode requested. One of: backgroundRemoval, foregroundMatting.

Request Body

Name Required Type Description
url True

string

Publicly reachable URL of an image.

Responses

Name Type Description
200 OK

file

Success

Media Types: "image/png", "application/json"

Other Status Codes

ErrorResponse

Error

Media Types: "image/png", "application/json"

Headers

x-ms-error-code: string

Examples

Segment_BackgroundRemoval_FromImageUrl
Segment_ForegroundMatting_FromImageUrl

Segment_BackgroundRemoval_FromImageUrl

Sample Request

POST /imageanalysis:segment?mode=backgroundRemoval&api-version=2023-02-01-preview

{
  "url": "{image url}"
}

Sample Response

"Ynl0ZXM="

Segment_ForegroundMatting_FromImageUrl

Sample Request

POST /imageanalysis:segment?mode=foregroundMatting&api-version=2023-02-01-preview

{
  "url": "{image url}"
}

Sample Response

"Ynl0ZXM="

Definitions

Name Description
ErrorResponse

Response returned when an error occurs.

ErrorResponseDetails

Error info.

ErrorResponseInnerError

Detailed error.

ImageUrl

A JSON document with a URL pointing to the image that is to be analyzed.

SegmentationModeApiModel

The analysis mode requested. One of: backgroundRemoval, foregroundMatting.

ErrorResponse

Response returned when an error occurs.

Name Type Description
error

ErrorResponseDetails

Error info.

ErrorResponseDetails

Error info.

Name Type Description
code

string

Error code.

details

ErrorResponseDetails[]

List of detailed errors.

innererror

ErrorResponseInnerError

Detailed error.

message

string

Error message.

target

string

Target of the error.

ErrorResponseInnerError

Detailed error.

Name Type Description
code

string

Error code.

innererror

ErrorResponseInnerError

Detailed error.

message

string

Error message.

ImageUrl

A JSON document with a URL pointing to the image that is to be analyzed.

Name Type Description
url

string

Publicly reachable URL of an image.

SegmentationModeApiModel

The analysis mode requested. One of: backgroundRemoval, foregroundMatting.

Name Type Description
backgroundRemoval

string

foregroundMatting

string