IMREAD(1)

NAME
imread - reads image file in ANY format

SYNOPSIS
       Image = imread(filename)
[Index, Map] = imread(filename)

PARAMETERS

filename
    A string, the image filename to be read. The extension determines the type of the image.

Image
    For truecolor images, this is a MxNx3 matrix in range 0-255 (8 bits per pixel) or 0-65535 (16 bpp); For binary images, image is a MxNx1 matrix (0=black and 1=white).

Index
    MxN matrix containing the indexes to the image colormap (for indexed images). Indices start at 0.

Map Mx3 matrix containing the image colormap. Entries range from 0 to 65535.

DESCRIPTION
imread reads BMP, GIF, JPEG, PNG, PCX, TIFF, XPM, and even more types of image files into Scilab. The format of the file is inferred from the extension in the filename parameter.

Img = imread(filename) reads image in filename into Img matrix. If filename contains a truecolor image, Img is a MxNx3 hypermatrix, so for example Img(:,:,1) stands for the red channel. For binary images, Img is a MxNx1 matrix.

[Index,Map] = imread(filename) reads the indexed image in filename into Index (MxN) and Map (Mx3), its colormap. Grayscale and Paletted images are read in this way.

To know if the image stored in filename is truecolor or indexed, you can use the imfinfo command, and then call imread accordingly.

EXAMPLE
initial_dir = PWD;
chdir (SIPDIR + 'examples');
imfinfo('example.png','verbose');
// the image is indexed
[im,i] = imread('example.png');
xbasc();
imshow(im,i);
chdir(initial_dir);

REMARKS
It is not natural to assume that indexes (from paletted images) start at 0, since Scilab indexing start at 1. However, we had to make that assumption because in the near future, the SIP toolbox will make use of unsigned integer types, which start at 0. In theory, imread will read any raster image format. In practice, it has been tested only for BMP, GIF, JPEG, PNG, PCX, TIFF, XPM, and MIFF. Reading other formats will probably work, but have not been tested by the developers of the SIP toolbox.

BUGS AND SHORTCOMINGS
Images are stored in double precision matrices. Hopefully, the next release will make usage of integer types.

AUTHORS
Ricardo Fabbri <rfabbri@if.sc.usp.br>

AVAILABILITY
The latest version of the Scilab Image Processing toolbox can be found at

    http://cyvision.if.sc.usp.br/~rfabbri/sip/

SEE ALSO
imwrite, imfinfo, imshow