Image Processing Toolbox User's Guide Previous page   Next Page

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:

  1. Read image and display it.
  2. Create an indexed image with eight colors and without dithering.
  3. Create an indexed image using eight colors with dithering.

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.


Previous page  Reducing Colors in an Indexed Image Converting Color Data Between Color Spaces Next page

© 1994-2005 The MathWorks, Inc.