帮助中心帮助中心
从数据存储读取指定的图像
img = readimage(imds,I)
[img,fileinfo] = readimage(imds,I)
示例
img = readimage(imds,I) 从数据存储 imds 读取第 I 个图像文件并返回图像数据 img。img 数组的大小和数据类型取决于数据存储中的文件的图像格式。readimage 函数支持的图像格式与 imread 函数支持的图像格式相同。有关支持的格式的详细信息,请参阅 imread。
img
imds
I
readimage
imread
[img,fileinfo] = readimage(imds,I) 还会返回一个结构体 fileinfo,其中包含两个文件信息字段:
fileinfo
Filename - 从中读取图像的文件的名称。
Filename
FileSize - 文件大小(以字节为单位)。
FileSize
全部折叠
创建一个 ImageDatastore 对象,其中包含两个图像,然后读取并查看第二个图像。
ImageDatastore
imds = imageDatastore({'street1.jpg','street2.jpg'}); img = readimage(imds,2); imshow(img)
创建一个数据存储对象,其中包含两个图像,然后读取第二个图像。
imds = imageDatastore({'street1.jpg','street2.jpg'}); [img,info] = readimage(imds,2);
info 结构体包含第二个图像的以下信息:Filename、FileSize 和 Label。要显示文件名和路径,请在命令行窗口中键入 info.Filename。要显示文件大小,请键入 info.FileSize。
info
Label
info.Filename
info.FileSize
输入数据存储。可以使用 imageDatastore 函数或 datastore 函数根据您的数据创建数据存储对象。
imageDatastore
datastore
图像文件索引,指定为正整数。
数据类型: double
double
图像数据,以由整数组成的多维数组形式返回。img 的大小取决于图像格式:
对于灰度图像,是 m×n 数组
对于真彩色图像,是 m×n×3 数组
对于 CMYK Tiff 图像,是 m×n×4 数组
imread 支持的图像格式 readimage 函数都支持。有关支持的格式的详细信息,请参阅 imread。
文件信息,以结构体数组形式返回,其中包含两个字段:
数据类型: struct
struct
backgroundPool
ThreadPool
用法说明和限制:
readimage 在基于线程的环境中不支持以下图像格式:
分层数据格式 (HDF)
SVS
TIFF
有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
在 R2015b 中推出
datastore | imread | read | readall | ImageDatastore
read
readall
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office