1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
//! The color counter crate is a CLI tool //! to open an image and count it's pixel colors //! and divide this count by color region. //! //! The Space is the color space in its entirety, //! the Region is a piece of the color space. //! //! There is also a constants module, to define the boundaries //! of the color space, this is used to divide the color space //! and put every color on its 'bucket'. use color_processing::Color; use image::GenericImageView; /// Open an image in a path 'filepath' and /// store all it's pixels in a Vec of Colors. /// /// Effectively this just converts the reading of an /// image by the image crate to a Color in the color_processing /// crate format. pub fn get_colors(filepath: &str) -> Vec<Color> { let image = image::open(filepath).unwrap(); image .pixels() .map(|pixel| { let data = pixel.2.data; Color::new_rgba(data[0], data[1], data[2], data[3]) }) .collect() } pub mod constants; pub mod region; pub mod space;