coqnitics

coqnitics / colordetector / 0.1.1

README.md

Overview

The Color Detector API analyzes the color components of the image and returns the dominant colors in the image. The algorithm first segments the images using superpixel algorithms before perform clustering to obtain the important colors. The segmentation algorithm is important to identify the important components in the image before combining the color information.

Applicable Scenarios and Problems

The API enables analysis of the color composition of an item, and allows the user to carry out more advanced task such as recommendation and matching. e.g. recognize colors of clothes

Usage

Input

Our API takes in a json file with three parameter 'image','zoom_h','zoom_w'. 'image' contains the url of the actual image for analysis while 'zoom_h' and 'zoom_w' defines how much to zoom into the image, a more complete offset will be provided as a future feature. E.g. setting 'zoom_h' and 'zoom_w' to 0.5 will only look at the center 50% of the picture.

Describe the input fields for your algorithm. For example:

ParameterDescription
imageurl of the image
zoom_hzoom on height of the image
zoom_wzoom on width of the image

_

Output

The algorithm outputs up to 5 dominant colors (list) and the respective color information according to the popular Hollasch categorization. For consistency purposes, only colors that take up more than 15% of the image is returned. Each color consists of the following information:

ParameterDescription
color_nameColor Name
general_categoryColor Category
hexHex code
ratioRatio of Color

_

Examples

Case 1: Pass in image url

Input
{"image":"https://s3-ap-southeast-1.amazonaws.com/lprimg/jennifer_lawrence.png"}
Output
[{"color_name":"ivory_black",
"general_category":"Black",
"hex":"#302331",
"ratio":0.24324324324324328},
{"color_name":"black",
"general_category":"Black",
"hex":"#0a0406","ratio":0.21621621621621623},
{"color_name":"gainsboro",
"general_category":"White",
"hex":"#cfd8f2",
"ratio":0.2972972972972973}]

Case 2: Pass in image url and zoom information

Input
{"image":"https://s3-ap-southeast-1.amazonaws.com/lprimg/jennifer_lawrence.png",
"zoom_h":0.5,
"zoom_w":0.5}
Output
[{"color_name":"ivory_black",
"general_category":"Black",
"hex":"#27161d",
"ratio":0.45614035087719296}]