https://github.com/legraphista/image-color-diversity
Calculates color diversity
https://github.com/legraphista/image-color-diversity
Last synced: 3 months ago
JSON representation
Calculates color diversity
- Host: GitHub
- URL: https://github.com/legraphista/image-color-diversity
- Owner: legraphista
- License: mit
- Created: 2016-11-27T23:51:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-29T14:01:42.000Z (over 8 years ago)
- Last Synced: 2025-01-21T01:28:03.644Z (4 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Color Diversity
Basic CLI tool to calculate the color diversity of an image
## Install
```
npm i -g image-color-diversity
```## Usage
```
diversity [] [-c -h -o ]-c : Contrast value ranging from -255 to 255
-h : human readable color index output
-o : output processed image to locationExamples:
diversity test.png -h -c 255
cat test.png | diversity -h -c 255
```### Example Output
The output is a JSON array.
Each item is an array containing:
- 0: color index
- 1: pixel count for the color index
- 2: percentage of the image covered by the color indexWithout -h flag
```
[ [ '16777215', 803331, 0.871669921875 ],
[ '0', 78899, 0.08561089409722222 ],
[ '255', 20825, 0.022596571180555556 ],
[ '65535', 15914, 0.01726779513888889 ],
[ '16711935', 1098, 0.00119140625 ],
[ '8454143', 592, 0.0006423611111111111 ],
[ '33023', 480, 0.0005208333333333333 ],
[ '128', 357, 0.00038736979166666667 ],
[ '8421504', 47, 0.00005099826388888889 ],
[ '8388863', 36, 0.0000390625 ],
[ '16744703', 14, 0.000015190972222222222 ],
[ '32896', 3, 0.0000032552083333333335 ],
[ '16711680', 3, 0.0000032552083333333335 ],
[ '65408', 1, 0.0000010850694444444444 ] ]
```With -h flag:
```
[ [ 'R255 G255 B255', 803331, 0.871669921875 ],
[ 'R0 G0 B0', 78899, 0.08561089409722222 ],
[ 'R255 G0 B0', 20825, 0.022596571180555556 ],
[ 'R255 G255 B0', 15914, 0.01726779513888889 ],
[ 'R255 G0 B255', 1098, 0.00119140625 ],
[ 'R255 G255 B128', 592, 0.0006423611111111111 ],
[ 'R255 G128 B0', 480, 0.0005208333333333333 ],
[ 'R128 G0 B0', 357, 0.00038736979166666667 ],
[ 'R128 G128 B128', 47, 0.00005099826388888889 ],
[ 'R255 G0 B128', 36, 0.0000390625 ],
[ 'R255 G128 B255', 14, 0.000015190972222222222 ],
[ 'R128 G128 B0', 3, 0.0000032552083333333335 ],
[ 'R0 G0 B255', 3, 0.0000032552083333333335 ],
[ 'R128 G255 B0', 1, 0.0000010850694444444444 ] ]
```