## Documentation Center |

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.

Most computer displays use 8, 16, or 24 bits per screen pixel. Depending on your system, you might be able to choose the screen bit depth you want to use. 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

An image might have finer gradations of color than a 16-bit display can represent. If a color is unavailable, MATLAB

^{®}uses the closest approximation.There are only 32 shades of gray available. If you are working primarily with grayscale images, you might get better display results using 8-bit display mode, which provides up to 256 shades of gray.

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

get(0,'ScreenDepth') ans = 32

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

Value | Screen Bit Depth |
---|---|

8 | 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 | 16-bit displays usually use 5 bits for each color component,
resulting in 32 (i.e., 2 |

24 | 24-bit displays use 8 bits for each of the three color
components, resulting in 256 (i.e., 2 |

32 | 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 Mapping Data to Transparency — Alpha Data in the MATLAB 3-D Visualization documentation. |

Regardless of the number of colors your system can display, MATLAB can
store and process images with very high bit depths: 2^{24} colors
for `uint8` RGB images, 2^{48} colors
for `uint16` RGB images, and 2^{159} 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 graphics documentation.) For
information about reducing the number of colors used by an image,
see Reducing the Number of Colors in an Image.

Was this topic helpful?