Search code examples
pythonrotationscikit-image

Why skimage rotate function receives interpolation method as an argument?


Using skimage rotate function I noticed it has an optional interpolation (order) parameter But I couldn't understand why.
The doc doesn't states how does it used, and I thought that rotating an image ends with a simple indexes shift.
Here is a picture, rotated by 30 degrees with both biliniar and NN interpolations, I can't state the difference of course.
enter image description here enter image description here


Solution

  • To rotate an image in an angle theta, it would be necessary to map each pixel P = (x, y) to a new point P' = (x', y'). How P is mapped to P' depends on the rotation axis and if theta is in degrees or radians, but it would be something like:

    • x' = x * cos(theta) - y * sin(theta)
    • y'= x * sin(theta) + y * cos(theta)

    the problem is that this results in non-integers values, here is where the interpolation comes in. To fill a pixel (x, y) in the rotated image, it would need to use a pixel with non-integer coordinates of the original image, interpolation approximates this non-integer point using the points nearby.