imread的应用

imread的应用

可移植性优化

[f_name,p_name] = uigetfile(’*.jpg; *.bmp; *.png’);
picture_read = imread([p_name f_name]);

imread

Read image from graphics file

Syntax语法

A = imread(filename)
A = imread(filename,fmt)
A = imread(___,idx)
A = imread(___,Name,Value)
[A,map] = imread(___)
[A,map,transparency
(透明度)] = imread(___)

A = imread(filename) reads the image from the file specified(指定) by filename, inferring (推理)the format of the file from its contents(内容). If filename is a multi-image file, then imread reads the first image in the file.

A = imread(‘ngc6543a.jpg’);

A = imread(filename,fmt) additionally(此外) specifies the format of the file with the standard file extension(扩展名) indicated(表明) by fmt. If imread cannot find a file with the name specified by filename, it looks for a file named filename.fmt.

A = imread(___,idx(索引文件)) reads the specified image or images from a multi-image file. This syntax applies only to GIF, CUR, ICO, and HDF4 files. You must specify a filename input, and you can optionally(随意的) specify fmt. (您必须指定文件名输入,并且可以选择指定fmt)

A = imread(___,Name,Value) specifies format-specific options using one or more name-value pair arguments(参数), in addition to any of the input arguments in the previous(先前的) syntaxes.

[A,map] = imread(___) reads the indexed(索引) image in filename into A and reads its associated colormap(色图) into map. Colormap values in the image file are automatically(自动) rescaled(重新调节) into the range [0,1].(范围)

[A,map,transparency] = imread(___) additionally returns the image transparency. This syntax applies only to PNG, CUR, and ICO files. For PNG files, transparency is the alpha channel(阿尔法通道), if one is present. For CUR and ICO files, it is the AND (opacity(不透明)) mask(模糊).

[X,map,alpha] = imread(‘peppers.png’);

Input Arguments

filename — File name 文件名
string
File name, specified as a string. If the file is not in the current folder or in a folder on the MATLAB® path, specify the full path name.

filename also can be an internet URL specifying an image location. The URL must include the protocol type (for example, http://).

For information on the bit depths, compression schemes, and color spaces supported for each file type, see Algorithms.

Example: ‘myFile.jpg’

Example: ‘http://www.mathworks.com/myImage.gif

Data Types: char

fmt — Image format文件扩展名
string
Image format, specified as a string indicating the standard file extension. Call imformats to see a list of supported formats and their file extensions.

Example: ‘png’

Data Types: char

idx — Image to read
integer scalar | vector of integers
Image to read, specified as an integer(整体) scalar(标量) or, for GIF files, a vector (矢量)of integers. For example, if idx is 3, then imread returns the third image in the file. For a GIF file, if idx is 1:5, then imread returns only the first five frames(框架). The idx argument is supported only for multi-image GIF, CUR, ICO, and HDF4 files.

When reading multiple frames from the same GIF file, specify idx as a vector of frames or use the ‘Frames’,‘all’ name-value pair argument. Because of the way that GIF files are structured, these syntaxes provide faster performance compared to calling imread in a loop.

For HDF4 files, idx corresponds to the reference number of the image to read. Reference numbers do not necessarily correspond to the order of the images in the file. You can use imfinfo to match image order with reference number.

Example: 3

Data Types: double

引用自MathWorks 公司 www.mathworks.com/help

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值