Package libsidplay.components.mos656x
Klasse OctreeQuantization
java.lang.Object
libsidplay.components.mos656x.OctreeQuantization
Classic octree color quantization algorithm. Given a histogram as packed
color value and count of occurences, computes and returns the optimal palette
when requested from the state of the tree.
The class operates on 24-bit colors. The components are called red, green and blue, but they can be anything. The components should be in some coding that compensates for eye's different sensitivity for errors in each component, as the color distance calculation and quantization assumes so.
- Autor:
- Antti Lankila
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Feldübersicht
FelderModifizierer und TypFeldBeschreibung(Package privat) final List<List<OctreeQuantization.Node>> Fast color lookup in least-squares sense- Each color is put in bucket.private static final intprotected final Set<OctreeQuantization.Node> List of current leaf nodes. leaf.parents are targets for reduction.private final intSize of palette to compute.private static final intBits per component in color lookup bucketprivate static final intBits per component(Package privat) final OctreeQuantization.NodeThe start of quantization tree. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected voidaddColor(int color, int weight) Add a color to quantization algorithm.private voidGenerate color buckets for faster color lookup.protected int[]Returns the optimized palette of constructor-time specified length.intlookup(int color) Do a nearest-node scan looking for best match.private voidquantize()Actually quantize the palette.
-
Felddetails
-
MAX_DEPTH
private static final int MAX_DEPTHBits per component- Siehe auch:
-
MAX_BUCKET_DEPTH
private static final int MAX_BUCKET_DEPTHBits per component in color lookup bucket- Siehe auch:
-
COMPONENT_MASK
private static final int COMPONENT_MASK- Siehe auch:
-
buckets
Fast color lookup in least-squares sense- Each color is put in bucket. -
root
The start of quantization tree. -
leaves
List of current leaf nodes. leaf.parents are targets for reduction. -
max
private final int maxSize of palette to compute.
-
-
Konstruktordetails
-
OctreeQuantization
protected OctreeQuantization(int max) Quantizer instance. Make a new quantizer for specific number of colors, add colors, and finally ask for palette.- Parameter:
max- size of palette to quantize to.
-
-
Methodendetails
-
addColor
protected void addColor(int color, int weight) Add a color to quantization algorithm.- Parameter:
color- The packed color to add.weight- Number of occurences of this color. (How important it is.)
-
quantize
private void quantize()Actually quantize the palette. Called when a palette is requested. -
getPalette
protected int[] getPalette()Returns the optimized palette of constructor-time specified length. Pads with 0 if more colors were requested than existed in source material. -
bucketStore
Generate color buckets for faster color lookup. Each color is distributed to the buckets at granularity of 2 bits per component (4 * 4 * 4 = 64 buckets in total).- Parameter:
node-
-
lookup
public int lookup(int color) Do a nearest-node scan looking for best match.- Parameter:
color- Color to get the best match of.- Gibt zurück:
- best node from simple scan
-