imread

Reads an image with the pixel data stored in a matrix R, with functions defined in the omlimgtoolbox.

Syntax

[R, dummy, alpha] = imread(file)

[R, dummy, alpha] = imread(file, ext)

[R, dummy, alpha] = imread(file, ..., 'PixelRegion', region)

Inputs

file
Name of the image file to be read.
Type: string
ext (optional)
Specifies the extension to use for the image file to be read. If this option is used, file should be the base name with no extension specified.
Type: string
region (optional)
Name-value pair to specify the pixel region of the image to be read. If specified, region is specified as a cell array, with two matrices of at least two elements each specifying the rows and columns. If the matrix elements of region have two elements, they specify the start and end pixels to be read for the rows/columns of the image region, respectively. If the matrix elements of region have more than two elements, they specify the start, increment, and end pixels to be read for the rows/columns of the image region, respectively.
Type: matrix

Outputs

R
The resulting matrix contains the pixel data for the image read. R is a 2-D matrix for gray scale images and a 3-D matrix otherwise.
Type: matrix
dummy
Dummy parameter which is ignored. It is there for script compatibility.
alpha
2-D matrix with values of the alpha channel.
Type: matrix

Examples

Read an image with default options:
addtoolbox('omlimgtoolbox')
m = imread('img_1640.jpg');
Read part of an image with alpha data, default pixel increments, and a file extension:
[m, dummy, alpha] = imread('productCompose-16', '.png', 'PixelRegion', {[2 7], [1 10]});
Read part of an image with alpha data, pixel increments, and a file extension:
[m, dummy, alpha] = imread('productCompose-16', '.png', 'PixelRegion', {[2 2 7], [1 10]});