Photodesk
FAQ  Tiles  Tutorials
Links     Galleries
Site information     Resources

Tutorial: One good turn...

...or even eighteen. This article was originally going to be just a brief overview of the rotation facilities in Photodesk, but while putting it together I came across something rather surprising....
[5991base/jpg]

Setting the scene

Rotating an image is a fairly common operation. Photodesk has a basic image rotation feature, accessed from the image menu Image>Rotate... or by Ctrl-R. Here's the dialogue:

[rotwin1/png]

The image rotation dialogue

Here are some general points to note about rotation:

The dialogue offers various options:

Test spin

Note

This is not something you'd ever do in real life, of course. The point of the repeated rotations is to amplify any deficiences in the algorithms used by Photodesk's rotation functions. Note that all rotation methods are lossy to some extent (apart from 90° multiples) – there are better algorithms than the ones Photodesk uses, but they're extremely processor-intensive.

I've carried out a simple trial to test how good each interpolation method is. Using the image at the top of the page, rotate it in 10° steps until it's upside down (for a total of 18 consecutive rotations), then Image>X flip and Image>Y flip to bring it the right way up again (the flips are lossless, so make no difference to the result). This is a fairly exacting test of any rotation algorithm.

All tests were carried out using Photodesk 3.06 on an Iyonix running RISC OS 5.11 with 512MB RAM.

I added the black rectangles and single-pixel white lines to see how well these would survive rotation.

The RISC OS feature of Adjust-clicks keeping dialogues open makes doing this operation very quick – set up the window as below and click Adjust on Rotate 18 times. I've used the Lose corners option as otherwise the image keeps on getting bigger and bigger (try it and see). The successive corner-chopping gives the circular effect seen below.

[rotwin2/png]

Setting up for the test

Here are the results for each method:

This is Bi-cubic interpolation (allegedly the best):

[5991cub/jpg]

Bicubic interpolation

This is Bi-linear interpolation (medium quality):

[5991lin/jpg]

Bilinear interpolation

And this is Nearest neighbour interpolation (low quality):

[5991nr/jpg]

Nearest neighbour interpolation

Commentary

Here's what the Photodesk manual says about the interpolation methods:
As usual, Bi-cubic is the highest quality but takes the longest. Nearest neighbour is the quickest but yields the poorest quality result. Bi-linear is a good compromise between speed and quality.
It's clear that Nearest neighbour is by far the worst, as expected. It's difficult to think of any reason for using this method, other than as a fast preview of rotating a very large image (but see the timings below).

The Bi-cubic interpolation, allegedly the best, also suffers from pixelisation and staircasing artefacts.

The Bi-linear interpolation, while blurred, is – to my eyes at least – clearly the best. Here's a detail of each, zoomed in to double size:

[5991detail/png]

Detail at double size

Bi-linear also responds well to sharpening, unlike the Bi-cubic method. Here I've applied Image processing:Sharpen (coarse) at 75% Strength:

[5991shdetail/png]

Sharpened at double size

Timings

I've also done some rough timings for each of the rotation methods. The image was 3498x3581 pixels at 24bpp; together with one main and one alpha channel this gives a total size of 64MB when loaded into Photodesk. If you're interested, it's an image of Mars taken by the Spirit rover, and can be found here. The image was chosen so that it and the undo buffer would fit into the 128MB dynamic area I'm using, so virtual memory is not an issue. Rotation was by 10°, with Lose corners selected.

I've also included the timing for Paint, though because Paint doesn't have a 'lose corners' option it's not strictly comparable (it has to resize the image too). And just to show that RISC OS machines aren't quite as slow as some people make out, the last row is for Photoshop 5 on a Mac Mini with 512MB RAM running OS X 10.39 (more RAM would doubtless speed this up, as would a more recent Photoshop; and note that like Paint, Photoshop does not offer a 'lose corners' option so the image is also being resized).

Bi-cubic13 sec
Bi-linear12 sec
Nearest neighbour11 sec
Paint15 sec
Photoshop/Mac Mini51 sec

There's not a huge difference in the Photodesk figures, perhaps suggesting that memory access is the critical bottleneck, rather than the algorithm.

Conclusions

Judging by this test, Bi-linear interpolation is the best. Given the almost identical timings, there's very little reason to use any other option, and Nearest neighbour should definitely be avoided.

According to theory (and practice in other graphics applications), Bi-cubic interpolation should be substantially better than it appears to be in Photodesk. It's possible that the implementation is flawed, or the dialogue could be triggering the wrong option (so selecting bilinear actually does bicubic, and vice versa).

Rob Davison's Variations also offers rotation, and has more options. There is no bicubic, but bilinear gives about the same result as the Bicubic option in Photodesk, supporting the theory that the latter program has got its options crossed.

I've reported these findings to the current maintainer, and await developments with interest.

Notes

TutorialOne good turn... by Chris and Lee
Created12:06pm Wed 4 Oct 2006 Last modified5:28pm Sun 22 Oct 2006
CategoryWhole image operations LevelBeginner