Color analysis

更新时间:
复制 MD 格式

Analyzes the colors of an input image and returns the main color values in RGB and HEX formats, along with their percentage in the image.

Introduction

  • Name: Color Palette Recognition

  • Action: RecognizeImageColor

This feature analyzes the colors of an input image. It returns the main color values in RGB and HEX formats, along with the percentage of the image that each color represents.

For the following input image:

Image

This service extracts the following color palette:

RGB

58/150/224

207/160/43

185/197/212

146/115/24

63/66/54

24/53/87

HEX

3A96E0

CFA02B

B9C5D4

927318

3F4236

183557

Percentage

0.374724

0.179412

0.15671

0.124081

0.0842831

0.0807904

Field definitions

Input fields:

Field

Type

Required

Description

url

string

Yes

The URL of the image.

colorCount

int

Yes

The number of colors to return in the palette. Valid values: 1 to 16.

Output fields:

Field

Type

Required

Description

colorTemplateList

List

Yes

A list of color templates. For more information, see the colorTemplate definition below.

Definition of the colorTemplate field

Field

Type

Required

Description

color

string

Yes

The RGB color value in hexadecimal format, such as 291A18.

label

string

Yes

The color label, such as gray or red.

percentage

float

Yes

The proportion must be a value in the range of [0.0, 1.0].

Example

Input

{
   "colorCount": 5,
   "url": "http://ivpd-demo.oss-cn-shanghai.aliyuncs.com/ivpd-demo/images/RecognizeImageColor/RecognizeImageColor.png"
}

Output

{
    "code": "0",
    "context": {
        "spanTime": 655,
        "trackId": "6468bdd515650731833841299e",
    },
    "error": false,
    "message": "success",
    "result": {
        "colorTemplateList": [
            {
                "color": "2C1C19",
                "percentage": "0.264323",
                "label": "gray"
            },
            {
                "color": "B4764E",
                "percentage": "0.235978",
                "label": "orange"
            },
            {
                "color": "D9B58A",
                "percentage": "0.230369",
                "label": "orange"
            },
            {
                "color": "754533",
                "percentage": "0.180188",
                "label": "orange"
            },
            {
                "color": "D8A22A",
                "percentage": "0.089143",
                "label": "orange"
            }
        ]
    },
    "success": true,
    "trackId": "6468bdd515650731833841299e"
}