Crate a_sixel

Source
Expand description

A-Sixel library for encoding sixel images.

§Basic Usage

use a_sixel::BitMergeSixelEncoderBest;
use image::RgbImage;

let img = RgbImage::new(100, 100);
println!("{}", <BitMergeSixelEncoderBest>::encode(&img));

§Choosing an Encoder

For a more detailed breakdown, here’s the encoders by average speed and quality against the test images (speed figures will vary) at 256 colors with Sierra dithering:

AlgorithmMSEDSSIMExecution Time (ms)Initial Buckets
adu15.560.00541473N/A
bit36.420.0132367N/A
bit-merge-low12.100.00465592^14
bit-merge10.960.004011982^18
bit-merge-better10.770.003921962^20
bit-merge-best10.750.003928502^21
focal11.720.004332532^21
k-means10.860.00406208N/A
k-medians18.680.007510688N/A
median-cut20.270.0061627N/A
octree (max-heap)66.600.0163589N/A
octree (min-heap)332.290.0890552N/A

Here’s the encoders at 16 colors with Sierra dithering:

AlgorithmMSEDSSIMExecution Time (ms)Initial Buckets
adu120.450.0371280N/A
bit182.070.0492247N/A
bit-merge98.100.03079932^18
focal107.170.033530452^21
k-means97.020.0297664N/A
k-medians171.200.04865792N/A
median-cut168.880.0381317N/A
octree (max-heap)546.050.0922341N/A
octree (min-heap)879.790.2536349N/A

Re-exports§

pub use crate::adu::ADUPaletteBuilder;
pub use crate::bit::BitPaletteBuilder;
pub use crate::bitmerge::BitMergePaletteBuilder;
pub use crate::focal::FocalPaletteBuilder;
pub use crate::kmeans::KMeansPaletteBuilder;
pub use crate::kmedians::KMediansPaletteBuilder;
pub use crate::median_cut::MedianCutPaletteBuilder;
pub use crate::octree::OctreePaletteBuilder;

Modules§

adu
Use Adaptive Distributive Units to “learn” the image’s color properties and select palette entries.
bit
Encodes a palette by bucketing bit ranges into a power of two number of buckets. This is very fast and produces ok results for most images at larger palette sizes (e.g. 256).
bitmerge
Uses BitSixelEncoder with k-means and agglomerative merging to build a palette.
dither
A collection of various dithering algorithms that can be used with the SixelEncoder to dither the result.
focal
Use weighted pixels based on the image’s spectral properties to provided weighted input to k-means.
kmeans
Use k-means clustering to determine a palette for the image.
kmedians
Uses k-medians to build a palette of colors.
median_cut
https://en.wikipedia.org/wiki/Median_cut
octree
Uses an octree to build a palette from an image.

Structs§

SixelEncoder
The main type for performing sixel encoding.

Traits§

PaletteBuilder
A trait for types that perform quantization of an image to a target palette size.

Type Aliases§

ADUSixelEncoder
BitMergeSixelEncoder
BitMergeSixelEncoderBest
BitMergeSixelEncoderBetter
BitMergeSixelEncoderLow
BitSixelEncoder
FocalSixelEncoder
KMeansSixelEncoder
KMediansSixelEncoder
MedianCutSixelEncoder
OctreeSixelEncoder