Crate a_sixel

Source
Expand description

A-Sixel library for encoding sixel images.

§Basic Usage

use a_sixel::KMeansSixelEncoder;
use image::RgbImage;

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

§Choosing an Encoder

  • I want fast encoding with good quality:
    • Use KMeansSixelEncoder or ADUSixelEncoder.
  • I’m time constrained:
    • Use ADUSixelEncoder, BitSixelEncoder, or OctreeSixelEncoder. You can customize ADU by lowering the STEPS parameter to run faster if necessary while still getting good results.
  • I’m really time constrained and can sacrifice a little quality:
    • Use BitSixelEncoder<NoDither>.
  • I want high quality encoding, and don’t mind a bit more computation:
    • Use FocalSixelEncoder.
    • This matters a lot less if you’re not crunching the palette down below 256 colors.
    • Note that this an experimental encoder. It will likely produce comparable or better results than other encoders, but may not always do so. On the test images, for my personal preferences, I think it’s slightly better - particularly at small palette sizes. It works by computing weights for each pixel based on saliancy maps and measures of local statistics. These weighted pixels are then fed into a weighted k-means algorithm to produce a palette.

Re-exports§

pub use crate::adu::ADUPaletteBuilder;
pub use crate::bit::BitPaletteBuilder;
pub use crate::focal::FocalPaletteBuilder;
pub use crate::kmeans::KMeansPaletteBuilder;
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).
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 kmeans.
kmeans
Use k-means clustering to determine a palette for the image.
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
BitSixelEncoder
FocalSixelEncoder
KMeansSixelEncoder
MedianCutSixelEncoder
OctreeSixelEncoder