First, all the dependencies and imports we'll need.
:dep image = "0.24.5"
// From https://gitlab.com/landreville/ciede2000
:dep ciede2000 = { path = "~/workspace/CIEDE2000" }
// From https://gitlab.com/landreville/antco
:dep antco = { path = "~/workspace/antco" }
:dep evcxr_image = "1.1"
:dep evcxr_runtime = "1.1.0"
:dep lab = "0.11.0"
use std::io::Cursor;
use std::collections::HashMap;
use lab;
use image;
use image::io::Reader as ImageReader;
use image::{ImageBuffer, Pixel, Rgb, RgbImage};
use ciede2000::ciede2000;
use antco::{aco, AcoParameters, distance_matrix};
use evcxr_image::ImageDisplay;
use evcxr_runtime;
I took this photo of a fuschia blossom shortly after I learned that growing fuschia was an option.
let mut img = ImageReader::open("fuchsia.jpg")?.decode()?;
let mut bytes: Vec<u8> = Vec::new();
img.write_to(&mut Cursor::new(&mut bytes), image::ImageOutputFormat::Png)?;
evcxr_runtime::mime_type("image/png").bytes(&bytes)