User Documentation
RAVL, Recognition And Vision Library
Ravl - Images - IO


Image Input and Output

RAVL includes a comprehensive mechanism for reading and writing objects from and to files in a uniform and transparent fashion. It is based around two global functions: Load and Save. In particular, there is a set of routines to handle a variety of image file formats, together with the ability to convert between several different pixel representations.

The generic load/save mechanism is described in Ravl.Core.IO. In order to invoke the libraries specific to image I/O, you need to:

  • insert this header file:
    #include "Ravl/IO.hh"
  • add this library in the
    USESLIBS = RavlImageIO ....

The generic load/save call can then be used in the usual way. For an example of how to use the system with images see (Remember: to compile this example you'll need the "RavlImageIO" library.)

To find what file formats and conversions are available, use the conv tool, with the following options:

-lf - list all known file formats
-lc - list all known conversions
-lt - list all known classes (?)
Here's a summary of currently supported formats. Supported natively in ravl are:
  • pgm Grey scale images.
  • ppm RGB colour images.
  • pbm Bit image
With RavlExtImgIO which uses various open source libraries you also get:
  • jpeg Lossy compressed images. Colour and grey scale. (Supports sequences stored in a single file.)
  • png Lossless compressed images. Colour and grey scale.
  • tiff Lossless compressed images.

Creating image converters

If you wish to load and save your own image type as ppm, pgm or any other file format that is already supported, and the particular conversion you want is not currently available, it is straightforward to add one to the collection (currently in Ravl/Image/ImageIO/ Following is an example for converting a byte image into a double image. For more information on writing converters see Ravl.Core.IO

ImageC< RealT> DPConvImageCT2RealImageCT(const ImageC< ByteT> &dat)  
  ImageC< RealT> ret(dat.Rectangle());
  for(Array2dIter2C< RealT,ByteT> it(ret,dat);it;it++) 
    it.Data1() = (RealT) it.Data2();
  return ret;


The argument in the function call indicates (as a ratio of the number of bytes in the respective pixels) the amount of information lost in the conversion. In this example, no information is lost, so the ratio is 1. For double to char conversion, the ration would be 8.
Maintainer:Charles Galambos, Bill Christmas, Documentation by CxxDoc: Tue Aug 13 10:00:52 2002