Reputation: 71
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?
Upvotes: 5
Views: 3474
Reputation: 41
After several tests: The rotation axes could be interpreted as the following:
If we use the number for given axes: 0 -- x axis; 1 -- y axis; 2 -- z axis;
axes = (1,0) and (0,1) is the same, which is x any y axes. The rotation plane is x-y plane.
axes = (1,2) and (2,1) is the same, which is y any z axes. The rotation plane is y-z plane.
axes = (2,0) and (0,2) is the same, which is x any z axes. The rotation plane is x-z plane.
Upvotes: 4
Reputation: 251568
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.
Upvotes: 7