Next: , Previous: Signal Processing, Up: Top


32 Image Processing

Octave can display images with the X Window System using the xloadimage program. 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.

Loading images only works with Octave's image format (a file with a matrix containing the image data, and a matrix containing the colormap). Contributions of robust, well-written functions to read other image formats are welcome. If you can provide them, or would like to improve Octave's image processing capabilities in other ways, please contact bug@octave.org.

— Function File: colormap (map)
— Function File: colormap ("default")

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)

Return a gray colormap with n entries corresponding to values from 0 to n-1. The argument n should be a scalar. If it is omitted, 64 is assumed.

— Function File: [img, map] = gray2ind ()

Convert a gray scale intensity image to an Octave indexed image.

— Function File: image (x, zoom)
— Function File: image (x, y, A, zoom)

Display 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. If zoom is omitted, the image will be scaled to fit within 600x350 (to a max of 4).

It first tries to use display from ImageMagick then xv and then xloadimage.

The axis values corresponding to the matrix elements are specified in x and y. At present they are ignored.

     
     
See also: imshow, imagesc, colormap.

— Function File: imagesc (A)
— Function File: imagesc (x, y, A)
— Function File: imagesc (..., zoom)
— Function File: imagesc (..., limits)
— Function File: B = imagesc (...)

Display a scaled version of the matrix A as a color image. The matrix is scaled so that its entries are indices into the current colormap. The scaled matrix is returned. If zoom is omitted, a comfortable size is chosen. If limits = [lo, hi] are given, then that range maps into the full range of the colormap rather than the minimum and maximum values of A.

The axis values corresponding to the matrix elements are specified in x and y, either as pairs giving the minimum and maximum values for the respective axes, or as values for each row and column of the matrix A. At present they are ignored.

     
     
See also: image, imshow.

— Function File: imshow (im)
— Function File: imshow (im, limits)
— Function File: imshow (im, map)
— Function File: imshow (R, G, B, ...)
— Function File: imshow (filename)
— Function File: imshow (..., string_param1, value1, ...)

Display the image im, where im can a 2-dimensional (gray-scale image) or a 3-dimensional (RGB image) matrix. If three matrices of the same size are given as arguments, they will be concatenated into a 3-dimensional (RGB image) matrix.

If limits is a 2-element vector [low, high], the image is shown using a display range between low and high. If an empty matrix is passed for limits, the display range is computed as the range between the minimal and the maximal value in the image.

If map is a valid color map, the image will be shown as an indexed image using the supplied color map.

If a file name is given instead of an image, the file will be read and shown.

If given, the parameter string_param1 has value value1. string_param1 can be any of the following:

`"display_range"'
value1 is the display range as described above.
`"InitialMagnification"'
value1 sets the zoom level in percent. If value1 is 100 the image is showed unscaled.
     
     
See also: image, imagesc, colormap, gray2ind, rgb2ind.

— Function File: ind2gray (x, map)

Convert an Octave indexed image to a gray scale intensity image. If map is omitted, the current colormap is used to determine the intensities.

     
     
See also: gray2ind, rgb2ntsc, image, colormap.

— Function File: [r, g, b] = ind2rgb (x, map)

Convert an indexed image to red, green, and blue color components. If map is omitted, the current colormap is used for the conversion.

     
     
See also: rgb2ind, image, imshow, ind2gray, gray2ind.

— Function File: [x, map] = loadimage (file)

Load an image file and it's associated color map from the specified file. The image must be stored in Octave's image format.

     
     
See also: saveimage, load, save.

— Function File: rgb2ntsc (rgb)

Image format conversion.

— Function File: ntsc2rgb (yiq)

Image format conversion.

— Function File: rgb_map = hsv2rgb (hsv_map)

Transform a colormap from the hsv space to the rgb space.

     
     
See also: rgb2hsv.

— Function File: hsv_map = rgb2hsv (rgb_map)

Transform a colormap from the rgb space to the hsv space.

A color n the RGB space consists of the red, green and blue intensities.

In the HSV space each color is represented by their hue, saturation and value (brightness). Value gives the amount of light in the color. Hue describes the dominant wavelegth. Saturation is the amount of Hue mixed into the color.

     
     
See also: hsv2rgb.

— Function File: ocean (n)

Create color colormap. The argument n should be a scalar. If it is omitted, 64 is assumed.

— Function File: [x, map] = rgb2ind (rgb)
— Function File: [x, map] = rgb2ind (r, g, b)

Convert and RGB image to an Octave indexed image.

     
     
See also: ind2rgb, rgb2ntsc.

— Function File: saveimage (file, x, fmt, map)

Save the matrix x to file in image format fmt. Valid values for fmt are

"img"
Octave's image format. The current colormap is also saved in the file.
"ppm"
Portable pixmap format.
"ps"
PostScript format. Note that images saved in PostScript format can not be read back into Octave with loadimage.

If the fourth argument is supplied, the specified colormap will also be saved along with the image.

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.

     
     
See also: loadimage, save, load, colormap.

— 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.