2 releases
Uses new Rust 2024
new 0.1.1 | Mar 11, 2025 |
---|---|
0.1.0 | Mar 11, 2025 |
#17 in #k-means
131 downloads per month
13KB
229 lines
🌟 Fluorescence
🦀 Rust | 🥮 Moonbit
An image library for color, blur, transformation, and feature extraction.
Image
This section is only provided for moonbit. There is no cake in moonbit that can load and parse images.
It is expected to support popular formats such as bmp, jpeg, png, etc.
Blur
Color
Kmeans
🦀 Rust
After installing this crates, We need to load the image from disk and pass it into a special data structure, which is prepared for no_std
environments (such as bare metal environments or WASM).
#[cfg(test)]
mod test {
use fluorescence::{
color::{self, PrimanyColor},
Image, RgbaColor,
};
use image::{GenericImageView, ImageReader};
#[test]
fn get_primany_colors_with_kmeans() {
let image_file = "./example/len_std.jpg";
let img = ImageReader::open(image_file).unwrap().decode().unwrap();
let pixels: Vec<RgbaColor> = img
.pixels()
.map(|pixel| {
let rgba = pixel.2;
RgbaColor {
r: rgba[0],
g: rgba[1],
b: rgba[2],
a: rgba[3],
}
})
.collect();
let width = img.width();
let heigth = img.height();
let kmeans = color::kmeans::Kmeans::new(
Image {
pixels,
width,
heigth,
},
1,
100,
1.0,
);
let colors = kmeans.get_primary_colors().unwrap();
println!("{:?}", colors);
}
}
🥮 Moonbit
When I found out that moonbit didn't even have a library that could read and parse jpeg or png images, it meant I needed some time to implement parsing images first. :(
Dependencies
~1.5MB
~20K SLoC