The class RImage

The class RImage image represents raster images. You will have to implement it step by step along the lab sessions. The specification of the class will evolve along the course with new methods.

class rimage.RImage(name, width=0, height=0, color=None, data=None)

Creates an instance of the class with the given name. If color is not none, the image has the given width and height and is uniformly filled with the given color. Otherwise, if data is not None, it is a pixel_array and the image is filled with it.

Class methods

procedural(name)

Returns an image created procedurally with the given procedure.

read(filename)

Returns the image of the filename. The name of the image is the file basename.

Instance attributes:

name

Name of the image (str)

Instance methods:

width()

Returns the width of the image

height()

Returns the heigth of the image

nchannels()

Returns the number of channels of the image

render_matplotlib(ax, params)

Renders the image with matplotlib_ in the given subplot with the given parameters.

Supported operations

Operation

Result

ima[i, j]

Returns the color of the pixel (i, j) \(0<=i<ima.width()\) \(0<=j<ima.height()\)

ima[i, j] = color

Assigns the color to the pixel (i, j) \(0<=i<ima.width()\) \(0<=j<ima.height()\)

The class supports the slicing mechanism and the functions: str.