Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'axes' parameter in scipy.ndimage.interpolation.rotate

I do not quite understand the parameter axes in the following rotate function:

scipy.ndimage.interpolation.rotate(input, angle, axes=(1, 0), reshape=True, output=None, order=3, mode='constant', cval=0.0, prefilter=True)

The explanation given in the doc is as following:

axes : tuple of 2 ints, optional

The two axes that define the plane of rotation. Default is the first two axes.

Can two axes define a plane of rotation?

like image 835
huskier Avatar asked Aug 24 '12 17:08

huskier


1 Answers

Ndimage is for working with multidimensional images. An n-dimensional image will have n axes. To do a rotation, you need to pick two axes to define a plane in which to do the rotation. This is what the axes parameter lets you specify.

The axes are numbered from 0 onwards. It's not 100% explicit in the documentation, but my interpretation is that "axis" here means the same thing as it does in Numpy in general, namely a dimension of the n-dimensional data structure, where zero is rows, one is columns, etc.. So (1, 0) means "the first and zeroth dimensions".

Passing (1, 1) would be meaningless, since that specifies the same axis twice. Passing (0, 1) would be the same as pasing (1, 0), but by passing the axes in the opposite order you would change the direction of the rotation.

like image 123
BrenBarn Avatar answered Sep 28 '22 10:09

BrenBarn