TIEGlobalSettings.ColorReductionAlgorithm
Declaration
property ColorReductionAlgorithm: integer;
Description
Specifies the algorithm used when converting from true color (24 bit) to color mapped images.
Color reduction is required for methods like saving to GIF (which supports a maximum of 256 colors).
Value | Description |
-1 | Automatically select best option (Median Cut when reducing to <128 colors, otherwise Kohonen) |
0 | Kohonen algorithm (See also: ColorReductionQuality) |
1 | Median Cut |
Kohonen AlgorithmThe algorithm performs quantization of 24-bit color images to lower depth, such as 8-bit color. The algorithm operates using a one-dimensional self-organizing Kohonen Neural Network, typically with 256 neurons, which self-organizes through learning to match the distribution of colors in an input image. Taking the position in RGB-space of each neuron gives a high-quality color map in which adjacent colors are similar. This map is then used to quantize the image.
By adjusting the
ColorReductionQuality, the network can either produce extremely high-quality images slowly, or produce good images in reasonable times. At highest quality, the entire image is used in the learning phase, while at lower qualities, a pseudo-random subset of pixels is used in the learning phase.
Median CutThis algorithm reduces colors by sorting colors by color channel and then recursively cutting each set of data at the median point in the channel with the greatest range. For example, if we want to reduce a palette to 16 colors, we would put all the pixels of the image (that is, their RGB values) in a bucket. Then calculate which color channel (red, green, or blue) among the pixels has the greatest range, and sort the pixels. After sorting, we move the upper half of the pixels into a new bucket (i.e. "cut" the lower half of the pixels). This process can then be repeated to further subdivide the set of pixels. After the desired number of buckets have been produced, the pixels in each bucket are averaged to get the final color palette.
Default: -1