Image Type Conversion
Image Processing Toolbox™ supports binary, indexed, grayscale, and truecolor image types. In each image type, pixels are stored in different formats. For example, truecolor images represent a pixel as a triplet of red, green, and blue values, whereas grayscale images represent a pixel as a single intensity value.
Pixel values of the different image types can be stored in floating-point, signed and unsigned integers, or logical data types. Toolbox functions enable you to convert between the image types and data types.
Convert Between Image Types
|Convert RGB colormap to grayscale colormap (Since R2020b)|
|Convert grayscale or binary image to indexed image|
|Convert RGB image to grayscale (Since R2020b)|
|Convert indexed image to grayscale image|
|Convert matrix to grayscale image|
|Convert RGB image or colormap to grayscale|
|Convert RGB color values to lightness values (Since R2019a)|
|Convert RGB image to indexed image|
|Convert indexed image to RGB image|
|Convert label matrix into RGB image|
|Convert Bayer pattern encoded image to truecolor image|
|Split multichannel image into its individual channels|
Convert to Binary Image Using Thresholding
Convert to Indexed Image Using Quantization
- Image Types in the Toolbox
Image types determine how MATLAB® interprets data matrix elements as pixel intensity values. The toolbox supports many image types including binary, grayscale, truecolor, multispectral, and label images.
- Convert Between Image Types
Certain image processing operations support only a subset of the image types. You can convert images between the image types to suit the operation.
- Convert Image Data Between Data Types
You can convert image data between data types using functions that automatically rescale and offset the original data.