Image Processing Toolbox User's Guide |
Approximate indexed image by one with fewer colors
Syntax
[Y,newmap] = imapprox(X,map,n)
[Y,newmap] = imapprox(X,map,tol)
Y = imapprox(X,map,newmap)
[...] = imapprox(...,dither_option
)
Description
[Y,newmap] = imapprox(X,map,n)
approximates the colors in the indexed image X
and associated colormap map
by using minimum variance quantization. imapprox
returns indexed image Y
with colormap newmap
, which has at most n
colors.
[Y,newmap] = imapprox(X,map,tol)
approximates the colors in X
and map
through uniform quantization. newmap
contains at most (floor(1/tol)+1)^3
colors. tol
must be between 0 and 1.0.
Y = imapprox(X,map,newmap)
approximates the colors in map
by using colormap mapping to find the colors in newmap
that best match the colors in map
.
Y = imapprox(...,dither_option)
enables or disables dithering. dither_option
is a string that can have one of these values. The default value is enclosed in braces ({}
).
Class Support
The input image X
can be of class uint8
, uint16
, or double
. The output image Y
is of class uint8
if the length of newmap
is less than or equal to 256. If the length of newmap
is greater than 256, Y
is of class double
.
Algorithm
imapprox
uses rgb2ind
to create a new colormap that uses fewer colors.
Example
Approximate the indexed image trees.tif
by another indexed image containing only 16 colors.
See Also
imagemodel | imattributes |
© 1994-2005 The MathWorks, Inc.