manpagez: man pages & more
info octave
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

31.1 Loading and Saving Images

The first step in most image processing tasks is to load an image into Octave. This is done using the imread function, which uses the GraphicsMagick library for reading. This means a vast number of image formats is supported. The imwrite function is the corresponding function for writing images to the disk.

In summary, most image processing code will follow the structure of this code

I = imread ("my_input_image.img");
J = process_my_image (I);
imwrite ("my_output_image.img", J);

Function File: [img, map, alpha] = imread (filename)

Read images from various file formats.

The size and numeric class of the output depends on the format of the image. A color image is returned as an MxNx3 matrix. Grey-level and black-and-white images are of size MxN. The color depth of the image determines the numeric class of the output: "uint8" or "uint16" for grey and color, and "logical" for black and white.

See also: imwrite, imfinfo.

Function File: imwrite (img, filename, fmt, p1, v1, …)
Function File: imwrite (img, map, filename, fmt, p1, v1, …)

Write images in various file formats.

If fmt is missing, the file extension (if any) of filename is used to determine the format.

The parameter-value pairs (p1, v1, …) are optional. Currently the following options are supported for JPEG images


Sets the quality of the compression. The corresponding value should be an integer between 0 and 100, with larger values meaning higher visual quality and less compression.

See also: imread, imfinfo.

Built-in Function: val = IMAGE_PATH ()
Built-in Function: old_val = IMAGE_PATH (new_val)

Query or set the internal variable that specifies a colon separated list of directories in which to search for image files.

It is possible to get information about an image file on disk, without actually reading it into Octave. This is done using the imfinfo function which provides read access to many of the parameters stored in the header of the image file.

Function File: info = imfinfo (filename)
Function File: info = imfinfo (url)

Read image information from a file.

imfinfo returns a structure containing information about the image stored in the file filename. The output structure contains the following fields.


The full name of the image file.


Number of bytes of the image on disk


Date of last modification to the file.


Image height in pixels.


Image Width in pixels.


Number of bits per channel per pixel.


Image format (e.g., "jpeg").


Long form image format description.


X resolution of the image.


Y resolution of the image.


Number of unique colors in the image.


Tile name.


Time in 1/100ths of a second (0 to 65535) which must expire before displaying the next image in an animated sequence.


Number of iterations to loop an animation (e.g., Netscape loop extension) for.


Endian option for formats that support it. Is either "little-endian", "big-endian", or "undefined".


Gamma level of the image. The same color image displayed on two different workstations may look different due to differences in the display monitor.


true if the image has transparency.


Image modulus depth (minimum number of bits required to support red/green/blue components without loss of accuracy).


JPEG/MIFF/PNG compression level.


Preferred number of colors in the image.


Units of image resolution. Is either "pixels per inch", "pixels per centimeter", or "undefined".


Image type. Is either "grayscale", "indexed", "truecolor", or "undefined".


FlashPix viewing parameters.

See also: imread, imwrite.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© 2000-2018
Individual documents may contain additional copyright information.