DsCpp
DsCpp

Reputation: 2489

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

Upvotes: 1

Views: 425

Answers (2)

Heitor Boschirolli
Heitor Boschirolli

Reputation: 111

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.

Upvotes: 2

Andrew
Andrew

Reputation: 970

What you are doing is warping the image.

For example, imagine if you wanted to rotate the above image but ensure that none of the rotates picture was out of bounds. You would want to rotate, but also warp the axes so that you could see the entire image.

See http://scikit-image.org/docs/dev/api/skimage.transform.html#skimage.transform.warp for detail and other use-cases.

Upvotes: 0

Related Questions