Image Processing Toolbox User's Guide |
Dithering
When you use rgb2ind
or imapprox
to reduce the number of colors in an image, the resulting image might look inferior to the original, because some of the colors are lost. rgb2ind
and imapprox
both perform dithering to increase the apparent number of colors in the output image. Dithering changes the colors of pixels in a neighborhood so that the average color in each neighborhood approximates the original RGB color.
For an example of how dithering works, consider an image that contains a number of dark orange pixels for which there is no exact match in the colormap. To create the appearance of this shade of orange, the Image Processing Toolbox selects a combination of colors from the colormap, that, taken together as a six-pixel group, approximate the desired shade of pink. From a distance, the pixels appear to be the correct shade, but if you look up close at the image, you can see a blend of other shades. This example loads a 24-bit image, and then use rgb2ind
to create two indexed images with just eight colors each:
Notice that the dithered image has a larger number of apparent colors but is somewhat fuzzy-looking. The image produced without dithering has fewer apparent colors, but an improved spatial resolution when compared to the dithered image. One risk in doing color reduction without dithering is that the new image can contain false contours.
Reducing Colors in an Indexed Image | Converting Color Data Between Color Spaces |
© 1994-2005 The MathWorks, Inc.