When I rotate an image in Photoshop, I try to rotate by an amount that is an integral divisor of 360 degrees, i.e. 36 degrees, 30 degrees, 18 degrees, etc. My thinking is that this will result in a better image, with fewer artifacts or “fuzziness” (or whatever) than if I rotate by non-integral divisor amounts like 21 degrees, 7.24 degrees, etc.
Is there any validity to my thinking here, or am I just wasting my time getting the rotation to be something integral? I know that anything other than an integral multiple of 90 degrees will necessarily result in some loss of precision, but is 45 any better than 43.42, or 30 better than 29?
Pixels are squares arranged in a regular grid. Anything other than 0, 90, 180, and 270 are going to suffer damage.
Probably the best way to figure it is that after the perfect up-down, left-right options, 45 degree angles are usually going to be the next best, because you have a fairly regular layout of the pixels in relation to the image. Instead of going one over each time, you’re going over one and up one. Next best would probably be over one and up two, or over two and up one (63.4 or 26.6 degrees, I think). Next best after that would be one over and three up or three over and one up. Etc.
But fundamentally, it’s going to depend a lot on what your original image is. Even a bunch of line drawings might look nice at a strange rotation, if the lines were all at an angle which matches the target. An image of regular gradient swirls will probably look fine no matter what angle you put it in. It will all just depend.
But certainly your method isn’t going to map particularly well to a computer screen. The problem isn’t how nicely things map up to radians, it’s how nicely things fit into a regular square grid.
In addition, the pixels are stored in blocks of 8x8 so the size of the image needs to be in those increments to even be rotated losslessly by 90 degrees. Here is one site that goes into it:
There are numerous programs to accomplish lossless rotation, you might look into one if you need it regularly.
I did my own image rotations long ago and found that excellent (though obviously not “lossless”) results were obtained by using bicubic interpolation in the obvious way — I rotated and re-rotated dozens of times using arbitrary angles with little degradation. (The cubic interpolater has a free parameter; I got best results by setting it to sharpen slightly more than the default.)
Looks like you got some technical answers with more info than I can give, but the direct answer to your question is that there is nothing at all special about integer degrees. The choice of the measurement units is completely arbitrary. It’s like saying should my door have a width of an integer number of inches.
Multiples of 90 are special, however, not because of the number itself but because the image is a grid of squares and rotating it at right angles is basically like turning your screen sideways. The first line of Sage Rat’s response is probably all you need to know.
360 isn’t a magic number. You can measure angles in radians or gradians. With the former, you’re practically guaranteed not have integer rotation amounts. With the former divisors of 100 would be the supposedly magic numbers.
Nice fractions of basic rotations will probably work out best. So half of a 45 degree turn (itself half of a 90 degree turn), 22.5 degrees, will have nicer Math than a 23 degree turn.
Cite? Rotations by multiples of 90° are extremely simple of course, but just now I experimented with a large image in GIMP and found that 45.00° was actually the slowest of several rotations I tried!
Angles very close to multiples of 90° allow rotations using smaller interpolation kernels. Disk access and cache utilization will be very important with large images. You’ve got me curious enough, I may download and examine GIMP’s rotation code!
By and large, with sufficiently large images and a sophisticated tool (PS, not a phone’s image manager), it’s a bit of a mug’s game to try and mathematically outguess the algorithm.
There’s the Math and then there’s the implementation. It would appear that whoever programmed GIMP’s rotation algorithm didn’t try to take advantage of the Math for certain nice angles. I suspect it was optimized instead for tiny rotations.
When GIMP rotates an image, does it enlarge the image to accommodate the entire original image? If so, a 45-degree rotation results in the largest output image. The speed may simply be correlated with the size of the output image.
ftg, the OP didn’t say anything to imply that he thought that 360 was a magic number. He’s not talking about integer numbers of degrees; he’s talking about integer fractions of a complete rotation. Now, it so happens that a lot of those fractions are also integer numbers of degrees, because 360 has a lot of factors, but under the OP’s logic, 1/7 rotation (51.428571 degrees), for instnce would also be a good angle.
Cite for the claim that 45° is especially easy to rotate? Have you thought about what’s actually involved?
No, it develops a new image within the existing canvas. (Don’t ask me for details — I’m a GIMP novice.) Because of this (and assuming the image is square as it was in my experiment), 45° is actually the angle where the fewest result pixels need to be constructed!
I don’t know why the speed variations. Disc access or cache utilization might play an important role.
One possibility: With Paeth’s three-shear algorithm, two shears are enough to get excellent accuracy when the angle is close to a multiple of 90°. It could be that the third shear — assuming they use Paeth’s method at all — is applied only when the angle is quite distant from a multiple of 90°, e.g. near 45°.
i used to think the same as you, roadfood … and would try hard as hell to maintain equilibrium with 0º and 90º rotations. in the end … just the opposite holds true.
for instance … when creating a gradient … “banding” effects can be minimized by just a 1º rotation (i.e. 91º). photoshop offers additional tools for playing around with image artifacts … most reside within the filters. and 1º is really quite extensive … many of the images i work with need to be rotated between .02º -.07º to maintain the aesthetic balance.
so … as far as maintaining 90º or 180º to keep pixels balanced … seems to not hold truth.