color_counter

Crates.iocolor_counter
lib.rscolor_counter
version0.2.3
sourcesrc
created_at2019-02-16 17:44:24.059732
updated_at2019-11-13 12:12:41.762096
descriptionA crate to inspect an image for most frequent colors.
homepage
repositoryhttps://github.com/aaneto/color_counter.rs
max_upload_size
id115193
size2,329,015
Adilson Neto (aaneto)

documentation

README

Color Counter

A project for getting the color distribution of one image.

The current version works by dividing the CIELAB color space linearly and creating "regions" of colors sorted by frequency.

Using

This command will divide the color space in 10 regions (10% of the dimension each), with 1000 regions in total, display the first 2 regions sorted by their most frequent color, and print the 2 most frequent colors of those regions, using the file forest.jpg.


cargo run -- -r 2 -c 2 -s 0.1 -f forest.jpg

Region 1
Color 1: rgb(142, 146, 113) Frequency: 48
Color 2: rgb(138, 142, 109) Frequency: 36

Region 2
Color 1: rgb(145, 149, 116) Frequency: 48
Color 2: rgb(148, 152, 119) Frequency: 46

To see the options:

cargo run -- --help

Project Conclusion

While doing this I realised that there is a whole thing about this kind of color extraction, such as color quantization, if I ever come with different implementations it will probably be made into a different crate (color quantize, maybe?).

Another thing to note, the CIELAB space is not linear and linear space division might not be ideal to this problem.

Webassembly notes

On the lib.rs there is a function called colors_from_bytes, that can be used from a webassembly context, I have tested that to work properly to some degree.

Commit count: 55

cargo fmt