Color Overview


Package Name

DvmColor

Description

The DvmColor package provides primitives and types for color related operations, such as color conversion and color quantization

Color Conversion

The Dali color conversion functions currently convert between YUV to RGB color spaces.   Specialized versions of the functions are provided for 4:4:4, 4:2:2, 4:1:1, and 4:2:0 subsamplings.

Color Quantization

Color quantization involves two steps: (1) determining an appropriate subset of colors and (2) mapping a full-color image to that subset.  Dali addresses problem (1) by providing a function that performs the Heckbert median-cut algorithm on a set of color to choose 256 good colors (C,Tcl).

One way to solve problem (2) is with a brute force search.  This could take a long time, unless the source image contains only a small number of color (e.g., 1000 colors).   In this case, simply caching results from previous lookups would provide significant performance improvement.  The ColorHashTable is designed to provide such a cache.

A ColorHashTable is a fixed size hash table that maps (r,g,b) triplets to integer values. The size of the hash table must be power of two (it is allocated by specifying the power). It uses open addressing since it's size is fixed and a double hashing probing is used to probe the hash table. Only insertion and retrieval functions are available for the moment since there is no use for deletion.

If the image contains a large number of colors (e.g., if almost every pixel contains a different color), caching the results of previous lookups won't help.  The central problem that must be solved is an efficient three-dimensional nearest neighbor search. In other words, given a color as an (r,g,b) triplet, we want to compute the closest point (in RGB space) among a small, fixed set of points.  The data structure that stores this map is called a VpTree.  The Dali color package contains functions to create and free VpTrees, initialize them for searching for the closest color among a set of (e.g., 256) colors, and for mapping a full-color image into that set using the VpTree.

Detailed Specification

Tcl specification
C API specification

Dependencies

DvmBasic and DvmImap

Example

Encode a PPM as a GIF [ C | Tcl ]


Last Updated :

Copyright © 1997-1998 by Cornell University. See the file license.txt for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.