From: Todd N. <to...@gm...> - 2005-02-15 20:14:36
|
On Sun, 13 Feb 2005 20:35:26 +0100, Justus Piater <Jus...@ul...> wrote: > Please try out the code (Todd!) and tell me what you think. Once I > have Todd's approval, this code (imrotate.m and imrotate_Fourier.m) > should replace the existing version of imrotate in CVS. > I've tried it out and it works fine, much better than the previous version. > There are two test functions, testimrotate and testrot90. Look at > their code and play with them. The other files are needed by these > two. > > Paul Kienzle <pki...@us...> wrote on Thu, 10 Feb 2005 > 07:09:00 -0500: > > > I'm disappointed that the current imrotate gives an incorrect result you > > showed in your example, and would like to see that addressed as well. > > Just to clarify: The corners were off by half a pixel due to a > round-off error. This error is dramatic for small matrices, but barely > noticeable for anything that merits being called an "image". > Nevertheless, bug is bug... and is fixed. I thought it may have been imperceptible with large images but am glad that you found a way fix it anyway, the fixes that I implemented were definitely not the greatest. > > For example, what happens if the angle is 269.999999? Discretizing > > the angle before checking if it is 270 would be useful. > > I strongly disagree. rot90 should only be used for _exact_ multiples > of 90 degrees. If not, how do we choose the tolerance? If the image is > large enough, the result will be different. Let the user decide. The > user can discretize the angle before calling imrotate() if s/he wants > to. > I agree with Justus on this point, for a very large image a small angle change will result in a different rotated image. However it may be possible to do something in the manner of this pseudocode: theta=89.99 cornersTheta = compute the corners for 89.99; cornersNinety = compute the corners for 90.00 if cornersTheta = cornersNinety theta = 90; end; The speedup for the few cases where the angle is so close to a multiple of 90 and the image is small enough that it makes no difference may not be worth the expense of doing the checks to determine this. > Todd Neal <to...@gm...> wrote on Thu, 10 Feb 2005 09:24:03 -0600: > > > I also modified the special cases so that it doesn't rely on rot90 > > Why? rot90 does exactly what's needed here. My code uses it happily. > I used array indexing and transposing to achieve the 90,180, and 270 degree rotations. If you look at rot90.m, the rotation is accomplished by these methods. Including the code in imrotate.m saves a function call to rot90 and should be a bit faster. Todd |