Go to the first, previous, next, last section, table of contents.


Image Processing

To display images using these functions, you must be using Octave with the X Window System, and you must have either xloadimage or xv installed. You do not need to be running X in order to manipulate images, however, so some of these functions may be useful even if you are not able to view the results.

Function File: colormap
Set the current colormap.

colormap (map) sets the current colormap to map. The color map should be an n row by 3 column matrix. The columns contain red, green, and blue intensities respectively. All entries should be between 0 and 1 inclusive. The new colormap is returned.

colormap ("default") restores the default colormap (a gray scale colormap with 64 entries). The default colormap is returned.

With no arguments, colormap returns the current color map.

Function File: gray (n)
Create a gray colormap with values from 0 to n. The argument n should be a scalar. If it is omitted, 64 is assumed.

Function File: gray2ind
Convert a gray scale intensity image to an Octave indexed image.

Function File: image
Display an Octave image matrix.

image (x) displays a matrix as a color image. The elements of x are indices into the current colormap and should have values between 1 and the length of the colormap.

image (x, zoom) changes the zoom factor. The default value is 4.

Function File: imagesc
Scale and display a matrix as an image.

imagesc (x) displays a scaled version of the matrix x. The matrix is scaled so that its entries are indices into the current colormap. The scaled matrix is returned.

imagesc (x, zoom) sets the magnification, the default value is 4.

Function File: imshow
Display images.

imshow (x) displays an indexed image using the current colormap.

imshow (x, map) displays an indexed image using the specified colormap.

imshow (i, n) displays a gray scale intensity image.

imshow (r, g, b) displays an RGB image.

Function File: ind2gray
Convert an Octave indexed image to a gray scale intensity image.

y = ind2gray (x) converts an indexed image to a gray scale intensity image. The current colormap is used to determine the intensities. The intensity values lie between 0 and 1 inclusive.

y = ind2gray (x, map) uses the specified colormap instead of the current one in the conversion process.

Function File: ind2rgb
Convert an indexed image to red, green, and blue color components.

[r, g, b] = ind2rgb (x) uses the current colormap for the conversion.

[r, g, b] = ind2rgb (x, map) uses the specified colormap.

Function File: loadimage
Load an image file.

[x, map] = loadimage (file) loads an image and it's associated color map from the specified file. The image must be stored in Octave's image format.

Function File: ocean (n)
Create color colormap. The argument n should be a scalar. If it is omitted, 64 is assumed.

Function File: rgb2ind
Convert and RGB image to an Octave indexed image.

[x, map] = rgb2ind (r, g, b)

Function File: saveimage
Save a matrix to disk in image format.

saveimage (file, x) saves matrix x to file in Octave's image format. The current colormap is also saved in the file.

saveimage (file, x, "img") saves the image in the default format and is the same as saveimage (file, x).

saveimage (file, x, "ppm") saves the image in ppm format instead of the default Octave image format.

saveimage (file, x, "ps") saves the image in PostScript format instead of the default Octave image format. (Note: images saved in PostScript format can not be read back into Octave with loadimage.)

saveimage (file, x, fmt, map) saves the image along with the specified colormap in the specified format.

Note: if the colormap contains only two entries and these entries are black and white, the bitmap ppm and PostScript formats are used. If the image is a gray scale image (the entries within each row of the colormap are equal) the gray scale ppm and PostScript image formats are used, otherwise the full color formats are used.

Built-in Variable: IMAGEPATH
A colon separated list of directories in which to search for image files.


Go to the first, previous, next, last section, table of contents.