rgb2ind
Convert RGB image to indexed image
Syntax
Description
Examples
Input Arguments
Output Arguments
Algorithms
Uniform Quantization — If you specify
tol, thenrgb2induses uniform quantization to convert the image. Uniform quantization cuts the RGB color cube into smaller cubes of lengthtol. For example, if you specify atolof 0.1, then the edges of the cubes are one-tenth the length of the RGB cube. The total number of small cubes is:t = (floor(1/tol)+1)^3
Each cube represents a single color in the output image. Therefore,
tis the maximum length of the colormap.rgb2indremoves any colors that do not appear in the input image, so the actual colormap can be smaller thant.Minimum Variance Quantization — If you specify
Q, thenrgb2induses minimum variance quantization. Minimum variance quantization cuts the RGB color cube into smaller boxes (not necessarily cubes) of different sizes, depending on how the colors are distributed in the image. If the input image actually uses fewer colors than the number specified, then the output colormap is also smaller.Inverse Colormap — If you specify an input colormap
inmap, thenrgb2induses colormap mapping. The inverse colormap algorithm quantizes the specified colormap into 32 distinct levels per color component. Then, for each pixel in the input image, the closest color in the quantized colormap is found.
References
[1] Spencer W. Thomas, "Efficient Inverse Color Map Computation", Graphics Gems II, (ed. James Arvo), Academic Press: Boston. 1991. (includes source code)
Version History
Introduced before R2006a
See Also
cmunique | dither | imapprox | ind2rgb
Topics
- Working with Image Types in MATLAB
- Reduce the Number of Colors in an Image (Image Processing Toolbox)

