User Guide

By importing this package, you can use Bob native array reading and writing routines to load and save files using various image formats.

>> import bob.io.base
>> import bob.io.image #under the hood: loads Bob plugin for image files
>> x = bob.io.base.load('myfile.jpg')

In the following example, an image generated randomly using the method NumPy numpy.random.random_integers(), is saved in JPEG format. The image must be of type uint8 or uint16:

>>> my_image = numpy.random.random_integers(0,255,(3,256,256))
>>> bob.io.base.save(my_image.astype('uint8'), 'testimage.jpg') # saving the image in jpeg format
>>> my_image_copy = bob.io.base.load('testimage.jpg')

The loaded image files can be 3D arrays (for RGB format) or 2D arrays (for greyscale) of type uint8 or uint16.

Previous topic

Bob’s Core I/O Routines

Next topic

Python API

This Page