检测图像中的配色方案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? |
---|---|
![]() |
truetrue |
![]() |
falsefalse |
使用 APIUse the API
配色方案检测功能属于分析图像 API。The color scheme detection feature is part of the Analyze Image API. 可以通过本机 SDK 或 REST 调用来调用此 API。You can call this API through a native SDK or through REST calls. 将 Color
包括在 visualFeatures 查询参数中。Include Color
in the visualFeatures query parameter. 然后,在获取完整 JSON 响应时,就只需分析 "color"
部分内容的字符串。Then, when you get the full JSON response, simply parse the string for the contents of the "color"
section.