Marcin
Marcin

Reputation: 238687

What interpolation is best for image rotation?

I have some images to rotate. I must rotate them (each by different angle) with as little as possible image artifacts (e.g. blurring) that occur during image rotation (due to interpolation).

At the moment I have GIMP 2.6 that has Cubic and Sinc(Lanczos3) interpolations available for image rotation. I'm not sure which one is better and introduces less artifacts? What are its disadvantaged, if any?

Also, is there some other software (e.g. a plugin for photoshop or gimp) or some script for Matlab that can provide near perfect image rotations (e.g. by using better interpolation algorithm than those available in GIMP)?

Many thanks in advance.

Upvotes: 9

Views: 5000

Answers (2)

Mark Ransom
Mark Ransom

Reputation: 308462

I remember seeing a comparison of different interpolation algorithms that was quite clever - the image was rotated by a fixed angle repeatedly until it was rotated all the way back to 360 degrees. Any artifacts or blurring were immediately obvious, and the image could be directly compared to the original. Edit: Found the link - http://www.all-in-one.ee/~dersch/interpolator/interpolator.html

Please don't think that Lanczos is the same as Sinc - they're related, but Lanczos trades some accuracy for ease of computation.

Upvotes: 6

sastanin
sastanin

Reputation: 41541

Another approach to image rotation is to apply two shear operations. See details in “A Fast Algorithm for General Raster Rotation” by Alan W. Paeth (can be found in the popular “Graphics Gems I” book in chapter 3 part 6 or here). As far as I understand, this method produces very crisp images.

ImageMagick's -rotate is implemented this way. So you may compare its results to the direct rotation method.

Upvotes: 4

Related Questions