检测图像中的配色方案Detect color schemes in images

计算机视觉分析图像中的颜色以便提供三种不同属性:主导前景色、主导背景色和图像的整体主导色的集。Computer Vision analyzes the colors in an image to provide three different attributes: the dominant foreground color, the dominant background color, and the set of dominant colors for the image as a whole. 返回色属于集:黑色、蓝色、棕色、灰色、绿色、橙色、粉红色、紫色、红色、青色、白色和黄色。Returned colors belong to the set: black, blue, brown, gray, green, orange, pink, purple, red, teal, white, and yellow.

计算机视觉还提取了代表图像中最鲜艳颜色的主题色,其基于主色和饱和度的组合。Computer Vision also extracts an accent color, which represents the most vibrant color in the image, based on a combination of dominant colors and saturation. 主题色作为十六进制 HTML 颜色代码返回。The accent color is returned as a hexadecimal HTML color code.

计算机视觉还返回布尔值,该值指示图像为黑色或白色。Computer Vision also returns a boolean value indicating whether an image is in black and white.

配色方案检测示例Color scheme detection examples

下面的示例说明了检测示例图像的配色方案时,计算机视觉所返回的 JSON 响应。The following example illustrates the JSON response returned by Computer Vision when detecting the color scheme of the example image. 在这种情况下,示例图不是黑色和白色的图像,但主导的前景色和背景色为黑色,并且图像的整体主导色为黑色和白色。In this case, the example image is not a black and white image, but the dominant foreground and background colors are black, and the dominant colors for the image as a whole are black and white.

日落时户外的大山以及人的轮廓

{
    "color": {
        "dominantColorForeground": "Black",
        "dominantColorBackground": "Black",
        "dominantColors": ["Black", "White"],
        "accentColor": "BB6D10",
        "isBwImg": false
    },
    "requestId": "0dc394bf-db50-4871-bdcc-13707d9405ea",
    "metadata": {
        "height": 202,
        "width": 300,
        "format": "Jpeg"
    }
}

主导色示例Dominant color examples

下表显示了针对每个示例图像返回的前景、背景和图像颜色。The following table shows the returned foreground, background, and image colors for each sample image.

映像Image 主色Dominant colors
具有绿色背景的白色花卉 前景色:黑色Foreground: Black
背景色:白色Background: White
颜色:黑色、白色、绿色Colors: Black, White, Green
穿过车站的火车 前景色:黑色Foreground: Black
背景色:黑色Background: Black
颜色:黑色Colors: Black

主题色示例Accent color examples

下表显示返回的十六进制 HTML 值形式的每个示例图像的主题色。The following table shows the returned accent color, as a hexadecimal HTML color value, for each example image.

映像Image 主题色Accent color
日落时站在山岩上的人 #BB6D10#BB6D10
具有绿色背景的白色花卉 #C6A205#C6A205
穿过车站的火车 #474A84#474A84

黑白检测示例Black & white detection examples

下表显示示例图像中的计算机视觉的黑色和白色计算。The following table shows Computer Vision's black and white evaluation in the sample images.

映像Image 黑色还是白色?Black & white?
曼哈顿建筑的黑白照片 true
一座蓝色的房子和前院 falsefalse

后续步骤Next steps

了解检测映像类型的概念。Learn concepts about detecting image types.