Previous Up Next

26.1.8  Extracting data from images

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 20.2.2.)


Previous Up Next