POST count_image_colors¶
Given a list of images or a list of image URLs and given a color palette, generate counters for each color from the palette specifying how many of the input images contain that color.
The response to this request will contain each input palette color along with two counters and a color class. The first counter (num_images_partial_area) gives how many of the input images contain the palette color (in any percentage). The second counter (num_images_full_area) gives how many of the input images contain the palette color in a very large percentage (are mostly covered by that color). Each color is associated with one or more of the following main color classes: white, black, grey-light, grey, grey-dark, red-light, red, red-dark, pink-light, pink, pink-dark, orange-light, orange, orange-dark, green-light, green, green-dark, yellow-light, yellow, yellow-dark, blue-light, blue, blue-dark, violet-light, violet, violet-dark, brown-light, brown and brown-dark.
Resource URL¶
https://multicolorengine.tineye.com/<company>/rest/count_image_colors/
Image limitations¶
Image size: For optimal performance, uploaded images (those given by image[n] parameters) should be 600px in size in the smallest dimension. For example, 1200x800 pixels is larger than required and it will take longer to transfer this file to your MulticolorEngine server. It would be faster to resize this image to be 900x600 and then send it. Smaller images may work, and need not be scaled up.
Image format: Accepted formats are JPEG, PNG, WEBP, AVIF, GIF, BMP and TIFF files. Animated images are not supported.
Parameters¶
In addition to the Common parameters there are:
Image¶
Key |
Description |
---|---|
image |
An image file object whose colors will be counted. |
Images¶
Key |
Description |
---|---|
images[0] |
An image file object whose colors will be counted. |
… |
… |
images[n] (optional) |
An image file object whose colors will be counted. |
URL¶
Key |
Description |
---|---|
url |
A URL of an image file whose colors will be counted. |
URLs¶
Key |
Description |
---|---|
urls[0] |
A URL of an image file whose colors will be counted. |
… |
… |
urls[n] (optional) |
A URL of an image file whose colors will be counted. |
For images and URLs¶
Key |
Description |
ignore_background (optional) |
Whether to detect and ignore the background region of the image files, can be either true or false, defaults to false. |
ignore_interior_background (optional) |
Whether to detect and ignore regions that have the same color as the background region but are surrounded by one or more non background regions, can be either true or false, defaults to false. |
count_colors[0] |
A color which you want to count. Can be entered in either RGB format (255,255,255) or hex format (ffffff). |
… |
… |
count_colors[n] (optional) |
A color which you want to count. |
Request examples¶
Images¶
curl https://multicolorengine.tineye.com/<company>/rest/count_image_colors/ \
-F "images[0]=@image1.jpg" \
-F "images[1]=@image2.jpg" \
-F "ignore_background=false" \
-F "ignore_interior_background=false" \
-F "count_colors[0]=255,112,223" \
-F "count_colors[1]=95,136,165" \
-F "count_colors[2]=DF4F23"
URLs¶
curl https://multicolorengine.tineye.com/<company>/rest/count_image_colors/ \
-F "urls[0]=http://example.com/image1.jpg" \
-F "urls[1]=http://example.com/image2.jpg" \
-F "count_colors[0]=255,112,223" \
-F "count_colors[1]=95,136,165" \
-F "count_colors[2]=DF4F23"
Response examples¶
JSON¶
{
"method": "count_image_colors",
"status": "ok",
"error": [],
"result": [
{
"color": [
105,
112,
223
],
"num_images_full_area": 0,
"num_images_partial_area": 0,
"class": "blue-light,violet-light"
},
{
"color": [
95,
136,
165
],
"num_images_full_area": 0,
"num_ images_partial_area": 0,
"class": "blue-light,grey"
},
{
"color": "df4f23",
"num_images_full_area": 1,
"num_images_partial_area": 1,
"class": "orange,red"
}
],
"stats": {
"time_resize": 46.82,
"time_count": 129.22,
"time_total": 176.61
}
}
XML¶
<?xml version="1.0" encoding="utf-8"?>
<data>
<method>count_image_colors</method>
<status>ok</status>
<error/>
<result>
<item>
<color>
<item>105</item>
<item>112</item>
<item>223</item>
</color>
<num_images_full_area>0</num_images_full_area>
<num_images_partial_area>0</num_images_partial_area>
<class>blue-light,violet-light</class>
</item>
<item>
<color>
<item>95</item>
<item>136</item>
<item>165</item>
</color>
<num_images_full_area>0</num_images_full_area>
<num_images_partial_area>0</num_images_partial_area>
<class>blue-light,grey</class>
</item>
<item>
<color>df4f23</color>
<num_images_full_area>1</num_images_full_area>
<num_images_partial_area>1</num_images_partial_area>
<class>orange,red</class>
</item>
</result>
<stats>
<time_resize>46.82</time_resize>
<time_count>129.22</time_count>
<time_total>176.61</time_total>
</stats>
</data>