Main Content

Display Colors

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.


The integer that 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 (that is, 25) levels each of red, green, and blue. This supports 32,768 (that is, 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 (that is, 216).


24-bit displays use 8 bits for each of the three color components, resulting in 256 (that is, 28) levels each of red, green, and blue. This supports 16,777,216 (that is, 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 Add Transparency to Graphics Objects.

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.

On systems with 16-bit screen bit depths, truecolor images are still displayed reasonably well because MATLAB automatically uses color approximation and dithering if needed. Color approximation is the process by which the software chooses replacement colors in the event that direct matches cannot be found. For information about reducing the number of colors used by an image, see Reduce the Number of Colors in an Image.

Related Topics