Crate a_sixel

Source
Expand description

A-Sixel library for encoding sixel images.

§Basic Usage

use a_sixel::ADUSixelEncoder;
use image::RgbImage;

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

§Choosing an Encoder

  • I want fast encoding with good quality:
  • I’m time constrained:
    • Use ADUSixelEncoder or BitSixelEncoder. 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:
  • 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 better results than just ADUSixelEncoder, but it may not always do so. On the test images, for my personal preferences, I think it’s slightly better - particularly at small palette sizes.

      How it works

      Under the hood, it is a modified version of the ADUSixelEncoder that uses a weighted selection algorithm for its sample pixels. These weights are determined based on saliency maps and measures of statistical noise in the image.

      In addition to the weighted selection, the distance metric used to determine which cluster to place a pixel into also incorporates the weight. Similar pixels with different weights will be nudged towards clusters with similar weights. This is a mild effect, but it seems to improve things over basic clustering when there are a lot of similar colors in an image.

Modules§

dither

Structs§

ADUPaletteBuilder
Use Adaptive Distributive Units to “learn” the image’s color properties and select palette entries.
BitPaletteBuilder
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).
FocalPaletteBuilder
Use weighted pixels based on the image’s spectral properties to select input to ADU.
MedianCutPaletteBuilder
https://en.wikipedia.org/wiki/Median_cut
SixelEncoder
The main type for performing sixel encoding.

Traits§

PaletteBuilder

Type Aliases§

ADUSixelEncoder
ADUSixelEncoder8
ADUSixelEncoder16
ADUSixelEncoder32
ADUSixelEncoder64
ADUSixelEncoder128
ADUSixelEncoder256
ADUSixelEncoder256High
BitSixelEncoder
BitSixelEncoder4
BitSixelEncoder8
BitSixelEncoder16
BitSixelEncoder32
BitSixelEncoder64
BitSixelEncoder128
BitSixelEncoder256
BitSixelEncoderMono
FocalSixelEncoder
FocalSixelEncoder4
FocalSixelEncoder8
FocalSixelEncoder16
FocalSixelEncoder32
FocalSixelEncoder64
FocalSixelEncoder128
FocalSixelEncoder256
FocalSixelEncoder256High
FocalSixelEncoderMono
MedianCutSixelEncoder
MedianCutSixelEncoder4
MedianCutSixelEncoder8
MedianCutSixelEncoder16
MedianCutSixelEncoder32
MedianCutSixelEncoder64
MedianCutSixelEncoder128
MedianCutSixelEncoder256
MedianCutSixelEncoderMono