# Image Color Summarizer

RGB, HSV, LCH & Lab image color statistics and clustering—simple and easy

## API

To automate your analysis, call this script as follows

$http://mkweb.bcgsc.ca/color-summarizer/?url=IMAGE_URL&precision=PRECISION&text=1$

where $IMAGE_URL$ is the URL of the input image (leading $http://$ is not necessary).

For this to work your image must be accessible by my server. Make sure you provide the URL to the image and not just to the page that contains the image.

### image is resized for analysis

Before it is analyzed, the image is resized—$precision$ controls the width of the resized image. This is done because the code that analyzes the image simply takes too long for large images.

The possible values of $PRECISION$ and the corresponding image size are

• $precision=vlow$ (50 px)
• $precision=low$ (75 px)
• $precision=medium$ (100 px)
• $precision=high$ (150 px)
• $precision=vhigh$ (200 px)

The default $precision$ is $medium$, which resizes the image to 100 pixels. The higher the precision, the longer it takes to process the image.

For example, to obtain a plain-text color summary of this Flickr image using $low$ precision,

$# plain-text output, output fields space-separated http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1$

### color clusters

Use $num_clusters=2..20$ to specify how many color clusters to report.

If you do not specify $num_clusters$ then the default value $num_clusters=5$ will be used.

If you set $num_clusters=0$ then no clustering will be performed.

$# no clustering http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&num_clusters=0 # 5 clusters http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&num_clusters=5$

### text, xml and JSON output

Use $text=1$, $xml=1$, $json=1$ and $jsnop=1$ to choose between plain-text, XML, JSON and JSONP output. The JSONP output is the same as JSON except that the output is wrapped in $colorsummary()$ function. The format of the output is explained below.

By default, plain-text output is space-delimited. To obtain tab-delimited output, add $tab=1$.

$# plain-text output, output fields space-separated http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1 # plain-text output, output fields tab-separated http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&tab=1 # XML output http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&xml=1 # JSON output http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&json=1 # JSONP output http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&jsonp=1$

### html output

If you omit the $text$ and $xml$, you will obtain color statistics in a formatted HTML table.

$# HTML output http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low$

The output will be the same as you obtain if you use the upload form and choose $html$ output.

### detailed reporting — histograms and pixel data

Histograms and pixel values are not shown by default. To include these use $histogram=1$ and/or $pixel=1$.

$# include histogram data http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&histogram=1 # include pixel data http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&pixel=1 # include histogram and pixel data http://mkweb.bcgsc.ca/color-summarizer/?url=static.flickr.com/37/88847543_d1eb68c5b9_m.jpg&precision=low&text=1&histogram=1&pixel=1$

### output format

The output plain-text format is designed to be

The output XML format should be self explanatory.