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:
- Use
ADUSixelEncoder BitSixelEncodercan also produce pretty good results for 256 colors depending on the image while being over 10x faster.
- Use
- I’m time constrained:
- Use
ADUSixelEncoderorBitSixelEncoder. You can customizeADUby lowering theSTEPSparameter to run faster if necessary while still getting good results.
- Use
- 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
ADUSixelEncoderthat 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§
Structs§
- ADUPalette
Builder - Use Adaptive Distributive Units to “learn” the image’s color properties and select palette entries.
- BitPalette
Builder - 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).
- Focal
Palette Builder - Use weighted pixels based on the image’s spectral properties to select input to ADU.
- Median
CutPalette Builder - https://en.wikipedia.org/wiki/Median_cut
- Sixel
Encoder - The main type for performing sixel encoding.
Traits§
Type Aliases§
- ADUSixel
Encoder - ADUSixel
Encoder8 - ADUSixel
Encoder16 - ADUSixel
Encoder32 - ADUSixel
Encoder64 - ADUSixel
Encoder128 - ADUSixel
Encoder256 - ADUSixel
Encoder256 High - BitSixel
Encoder - BitSixel
Encoder4 - BitSixel
Encoder8 - BitSixel
Encoder16 - BitSixel
Encoder32 - BitSixel
Encoder64 - BitSixel
Encoder128 - BitSixel
Encoder256 - BitSixel
Encoder Mono - Focal
Sixel Encoder - Focal
Sixel Encoder4 - Focal
Sixel Encoder8 - Focal
Sixel Encoder16 - Focal
Sixel Encoder32 - Focal
Sixel Encoder64 - Focal
Sixel Encoder128 - Focal
Sixel Encoder256 - Focal
Sixel Encoder256 High - Focal
Sixel Encoder Mono - Median
CutSixel Encoder - Median
CutSixel Encoder4 - Median
CutSixel Encoder8 - Median
CutSixel Encoder16 - Median
CutSixel Encoder32 - Median
CutSixel Encoder64 - Median
CutSixel Encoder128 - Median
CutSixel Encoder256 - Median
CutSixel Encoder Mono