Previous Page | Next Page

Commands Used with the IMGCTRL, IMGOP and PICFILL Functions

QUANTIZE



Reduces the number of colors used for an image
Syntax
Details
Example

Syntax

rc = IMGOP(task-id, 'QUANTIZE', colors);
region-id=PICFILL(graphenv-id, type, ulr, ulc,
lrr, lrc, source<, 'QUANTIZE'<, arguments>>);

colors

is the number of colors to use for the image. The value of the colors variable must be between 2 through 256.

Type: Numeric


Details

QUANTIZE acts on the currently selected image. It generates a color-mapped image for which the command assigns the values in the color map. QUANTIZE results in a very good approximation of the image, with the possible negative effect that two or more images that are quantized to the same number of colors might still use different colors for each image. (The algorithm is an adaptation of the Xiaolin Wu algorithm, as described in Graphics Gems II.(footnote 1))


Example

Reduce the number of colors for an image to the number stored in NUMCOLOR:

if (quantize eq 1) then
    rc=imgop(task-id,'QUANTIZE',numcolor);


FOOTNOTE 1:   Wu, Xiaolin (1991), " Efficient Statistical Computations for Optimal Color Quantization," in Graphics Gems II, ed. J. Arvo, Boston: Academic Press, 126-133. [arrow]

Previous Page | Next Page | Top of Page