Main Content

Image Type Conversion

Convert between the image types, such as RGB (truecolor), binary, grayscale, and indexed images, and change the data type of an image

Image Processing Toolbox™ supports binary, indexed, grayscale, and truecolor图像类型. 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 logicaldata types. Toolbox functions enable you to convert between the image types and data types.

Functions

expand all

cmap2gray Convert RGB colormap to grayscale colormap
gray2ind Convert grayscale or binary image to indexed image
im2gray Convert RGB image to grayscale
ind2gray Convert indexed image to grayscale image
mat2gray Convert matrix to grayscale image
RGB2Gray Convert RGB image or colormap to grayscale
rgb2lightness Convert RGB color values to lightness values
rgb2ind Convert RGB image to indexed image
ind2rgb Convert indexed image to RGB image
Label2RGB Convert label matrix into RGB image
demosaic Convert Bayer pattern encoded image to truecolor image
imsplit Split multichannel image into its individual channels
imbinarize Binarize 2-D grayscale image or 3-D volume by thresholding
adaptthresh Adaptive image threshold using local first-order statistics
otsuthresh Global histogram threshold using Otsu's method
graythresh 全球形象threshold using Otsu's method
imquantize Quantize image using specified quantization levels and output values
multithresh Multilevel image thresholds using Otsu’s method
grayslice 使用多级阈值将灰度图像转换为索引图像
im2double Convert image to double precision
im2int16 Convert image to 16-bit signed integers
im2single Convert image to single precision
im2uint16 Convert image to 16-bit unsigned integers
im2uint8 Convert image to 8-bit unsigned integers

Topics

  • 工具箱中的图像类型

    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

    某些图像处理操作仅支持图像类型的一个子集。万博1manbetx您可以在图像类型之间转换图像以适合操作。

  • Convert Image Data Between Data Types

    You can convert image data between data types using functions that automatically rescale and offset the original data.