Next: Displaying Images, Up: Image Processing

### 32.1 Loading and Saving Images

The first step in most image processing tasks is to load an image into Octave. Currently Octave only support saving images in the Portable Pixmap Format (PPM), PostScript, and Octave's own format, and loading images in Octave's format. Most image processing code will follow the structure of this code

         I = loadimage ("my_input_image.img");
         J = process_my_image (I);
         saveimage ("my_output_image.img", J);

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