Skip to content

Dominant Colors

Ximilar provides service for extracting dominant colors from image. Currently there are two endpoints to extract dominant colors. Each of the endpoint has specific use case.

https://api.ximilar.com/generic_photos/v2/dominantcolor
https://api.ximilar.com/product_photos/v2/dominantcolor

Contact us before using this service

In order to get access to the Dominant Colors services, please register at https://app.ximilar.com and then contact us at tech@ximilar.com to make the service accessible for your Ximilar account.

Generic Photos

https://api.ximilar.com/generic_photos/v2/dominantcolor

This endpoint detects, by default, up to 6 dominant colors from the whole image. The image is not transformed anyhow before the detection process.

Parameters:

  • records: A list of real-life photos to find similar products; each record
    • must contain either of _url or _base64 field
    • must contain collection field
  • colors - the maximum number of dominant colors to be returned, default: 6 (3 for product photos)

curl -H "Content-Type: application/json" -H "Authorization: Token XYZ" https://api.ximilar.com/generic_photos/v2/dominantcolor -d '{"color_names": true, "records":[{"_url":"https://www.ximilar.com/fashion_examples/1.jpg"}]}'

The result has similar json structure:

CLICK TO SHOW JSON RESULT

{
  "records": [
    {
      "_url": "https://www.ximilar.com/fashion_examples/1.jpg",
      "_status": {
        "text": "OK",
        "code": 200
      },
      "_dominant_colors": {
        "rgb_colors": [
          [
            97,
            90,
            94
          ],
          [
            226,
            225,
            232
          ],
          [
            156,
            111,
            92
          ],
          [
            52,
            93,
            136
          ]
        ],
        "rgb_hex_colors": [
          "#615a5e",
          "#e2e1e8",
          "#9c6f5c",
          "#345d88"
        ],
        "color_names": [
          "dimgrey",
          "gainsboro",
          "rosybrown",
          "steelblue"
        ],
        "luv_colors": [
          [
            39,
            3,
            -2
          ],
          [
            90,
            0,
            -5
          ],
          [
            51,
            32,
            19
          ],
          [
            39,
            -17,
            -40
          ]
        ],
        "percentages": [
          0.53,
          0.32,
          0.09,
          0.06
        ]
      },
      "_width": 600,
      "_height": 582
    }
  ],
  "color_names": true,
  "statistics": {
    "processing time": 0.4018435478210449,
  },
  "status": {
    "text": "OK",
    "code": 200
  }
}

Product Photos

https://api.ximilar.com/product_photos/v2/dominantcolor

This endpoint is meant for product photos with a single color background and a product, possibly a piece of clothes worn by a person. This endpoint:

  • filters the background
  • cuts the outer parts of the image to get rid of everything else but the product expected in the center
  • filters out human skin colors (now tuned mainly for Caucasian people)
  • first detects up to 6 dominant colors in the image, but then returns the 3 major colors (by area)

The endpoint has exact same params and workflow as for the generic photos.