Approximate indexed image by reducing number of colors
[Y,newmap] = imapprox(X,map,n)
[Y,newmap] = imapprox(X,map,tol)
Y = imapprox(X,map,newmap)
Y = imapprox(...,dither_option)
[Y,newmap] = imapprox(X,map,n) approximates
the colors in the indexed image
X and associated
map by using minimum variance quantization.
the indexed image
Y with colormap
which has at most
[Y,newmap] = imapprox(X,map,tol) approximates
the colors in
newmap contains at most
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
Y = imapprox(...,dither_option) enables
or disables dithering.
dither_option can have one
of these values.
Dithers, if necessary, to achieve better color resolution at the expense of spatial resolution.
Maps each color in the original image to the closest color in the new map. No dithering is performed.
The input image
X can be of class
double. The output image
uint8 if the length of
less than or equal to 256. If the length of
greater than 256,
Y is of class
Load an indexed image of a mandrill's face. Display image
X using its associated colormap,
map, which has 220 colors.
figure load mandrill image(X) colormap(map) axis off axis image
Reduce the number of colors in the indexed image from 220 to only 16 colors by producing a new image,
Y, and its associated colormap,
figure [Y,newmap] = imapprox(X,map,16); image(Y) colormap(newmap) axis off axis image
create a new colormap that uses fewer colors.