Image Processing Toolbox User's Guide Previous page   Next Page

Working with Different Screen Bit Depths

Most computer displays use 8, 16, or 24 bits per screen pixel. The number of bits per screen pixel determines the display's screen bit depth. The screen bit depth determines the screen color resolution, which is how many distinct colors the display can produce.

Regardless of the number of colors your system can display, MATLAB can store and process images with very high bit depths: 224 colors for uint8 RGB images, 248 colors for uint16 RGB images, and 2159 for double RGB images. These images are displayed best on systems with 24-bit color, but usually look fine on 16-bit systems as well. (For additional information about how MATLAB handles color, see the MATLAB graphics documentation.)

This section

Determining Screen Bit Depth

To determine the bit depth of your system's screen, enter this command at the MATLAB prompt.

The integer MATLAB returns represents the number of bits per screen pixel:

Screen Bit Depth
8-bit displays support 256 colors. An 8-bit display can produce any of the colors available on a 24-bit display, but only 256 distinct colors can appear at one time. (There are 256 shades of gray available, but if all 256 shades of gray are used, they take up all the available color slots.)
16-bit displays usually use 5 bits for each color component, resulting in 32 (i.e., 25) levels each of red, green, and blue. This supports 32,768 (i.e., 215) distinct colors (of which 32 are shades of gray). Some systems use the extra bit to increase the number of levels of green that can be displayed. In this case, the number of different colors supported by a 16-bit display is actually 64,536 (i.e. 216).
24-bit displays use 8 bits for each of the three color components, resulting in 256 (i.e., 28) levels each of red, green, and blue. This supports 16,777,216 (i.e., 224) different colors. (Of these colors, 256 are shades of gray. Shades of gray occur where R=G=B.) The 16 million possible colors supported by 24-bit display can render a lifelike image.
32-bit displays use 24 bits to store color information and use the remaining 8 bits to store transparency data (alpha channel). For information about how MATLAB supports the alpha channel, see the section Transparency" in the MATLAB graphics documentation.

Choosing a Screen Bit Depth

Depending on your system, you might be able to choose the screen bit depth you want to use. (There might be tradeoffs between screen bit depth and screen color resolution.) In general, 24-bit display mode produces the best results. If you need to use a lower screen bit depth, 16-bit is generally preferable to 8-bit. However, keep in mind that a 16-bit display has certain limitations, such as

For information about reducing the number of colors used by an image, see Reducing the Number of Colors in an Image.

Previous page  Color Reducing the Number of Colors in an Image Next page

© 1994-2005 The MathWorks, Inc.