Main Content

本页对应的英文页面已更新,但尚未翻译。 若要查看最新内容,请点击此处访问英文页面。

图像类型转换

在不同的图像类型(如 RGB(真彩色)、二值图像、灰度图像和索引图像)之间进行转换,并更改图像的数据类型

Image Processing Toolbox™ 支持二值、索引、灰度和真彩色图像类型。在每种图像类型中,像素以不同格式存储。例如,真彩色图像将像素表示为红、绿和蓝值的三元组,而灰度图像将一个像素表示为单个强度值。

不同图像类型的像素值可以以浮点、有符号和无符号整数或逻辑值数据类型存储。工具箱函数使您能够在图像类型和数据类型之间进行转换。

函数

全部展开

gray2indConvert grayscale or binary image to indexed image
ind2grayConvert indexed image to grayscale image
mat2grayConvert matrix to grayscale image
rgb2gray将 RGB 图像或颜色图转换为灰度图
rgb2lightnessConvert RGB color values to lightness values
rgb2ind将 RGB 图像转换为索引图像
ind2rgb将索引图像转换为 RGB 图像
label2rgbConvert label matrix into RGB image
demosaicConvert Bayer pattern encoded image to truecolor image
imsplitSplit multichannel image into its individual channels
imbinarize通过阈值化将二维灰度图像或三维体二值化
adaptthresh使用局部一阶统计量的自适应图像阈值
otsuthreshGlobal histogram threshold using Otsu's method
graythresh使用 Otsu 方法计算全局图像阈值
imquantizeQuantize image using specified quantization levels and output values
multithresh Multilevel image thresholds using Otsu’s method
graysliceConvert grayscale image to indexed image using multilevel thresholding
im2double将图像转换为双精度值
im2int16Convert image to 16-bit signed integers
im2singleConvert image to single precision
im2uint16Convert image to 16-bit unsigned integers
im2uint8将图像转换为 8 位无符号整数

主题

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 Classes

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

特色示例