Previous Up Next

28.1.8  Extracting data from images

Printing out information about an image.

The about command can be used to print out a brief description of an image object, which it takes as its only argument.

Obtaining the size of an image.

The size of an image can be obtained by using the size command.

Obtaining pixel data.

Channel data can be extracted from image objects to matrices by using the [] operator or the channel_data command.

Flattening images.

The flatten command returns a list representation of an image, which is suitable for e.g. passing the image to a neural network. It accepts a single argument, an image object img, and returns the list in which the pixel data is stored row by row, with individual channel values for the same pixel occupying consecutive entries in the list. (See the MNIST example in Section 22.2.2.)


Previous Up Next