From: Todd N. <to...@gm...> - 2005-02-10 15:24:12
Attachments:
imrotate.patch
|
Hello, I made a change where I round the corners matrix. In the tests that I performed it seems to provide for better rotations. I also modified the special cases so that it doesn't rely on rot90, etc. octave:160> a a = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Pre Patch: octave:161> imrotate(a,45) ans = 0 0 0 4 10 0 0 0 0 0 3 9 9 15 0 0 0 2 7 8 14 19 20 0 0 6 7 12 18 19 24 0 0 0 11 17 17 23 0 0 0 0 0 16 22 0 0 0 Post Patch: octave:162> imrotate(a,45) ans = 0 0 4 5 10 0 0 0 3 3 9 15 15 0 1 2 8 13 14 20 25 1 6 12 13 18 24 25 0 11 11 17 23 23 0 0 0 16 21 22 0 0 Todd |
From: Justus P. <Jus...@UL...> - 2005-02-10 18:36:29
|
Great to see that others too are interested in imrotate :-) Todd, thanks for reporting the half-pixel alignment problem revealed by the modulo-90 rotations. I think that the cause is incorrect round-off during computation of the center of rotation and/or the projection of the corners. I hope to be able to look into this over the weekend. In any case, a solution will have to be correct with respect to the homography (which is sub-pixel accurate when used with interpolation). In particular, the accelerated versions of the modulo-90 rotations must produce exactly the same result as the projection through the homography. BTW, I submitted a new version of imrotate to octave-dev on February 1st that adds bicubic interpolation and reintegrates Fourier interpolation. Cheers, Justus --=20 Justus H. Piater, Ph.D. http://www.montefiore.ulg.ac.be/~piater/ Institut Montefiore, B28 Phone: +32-4-366-2279 Universit=E9 de Li=E8ge, Belgium Fax: +32-4-366-2620 |
From: Todd N. <to...@gm...> - 2005-02-10 19:20:05
|
On Thu, 10 Feb 2005 19:36:13 +0100, Justus Piater <Jus...@ul...> wrote: > Great to see that others too are interested in imrotate :-) > > Todd, thanks for reporting the half-pixel alignment problem revealed > by the modulo-90 rotations. I think that the cause is incorrect > round-off during computation of the center of rotation and/or the > projection of the corners. I hope to be able to look into this over > the weekend. > I think the problem has to do with the rounding of the corners as well. octave:15> imrotate(a,180) corners = 0.00000 0.00000 -3.00000 -1.00000 -3.00000 -3.00000 -1.00000 -3.00000 ans = 9 8 7 6 5 4 3 2 1 0 0 0 After rounding the corners: octave:16> imrotate(a,180) corners = 0 0 -3 -1 -3 -3 -1 -3 ans = 9 8 7 6 5 4 3 2 1 > In any case, a solution will have to be correct with respect to the > homography (which is sub-pixel accurate when used with > interpolation). In particular, the accelerated versions of the > modulo-90 rotations must produce exactly the same result as the > projection through the homography. > If the corners matrix is rounded then imrotate(a,90) == rot90(a) so the accelerated version is equivalent. On second thought round is probably not the proper way to handle the corners matrix, maybe something like "round to the nearest integer if it is within some value epsilon", this should fix the multiple of 90 degree rotations. > BTW, I submitted a new version of imrotate to octave-dev on February > 1st that adds bicubic interpolation and reintegrates Fourier > interpolation. > I thought it may have been fixed in this version but it wasn't committed to CVS and I was not on the list at the time, can I get this patch ? I am working on imresize and would be interested in seeing the bicubic interpolation code. I am trying to clone Matlab's bilinear interpolation from looking at the results of a resized matrix but I think that it is possible that Matlab is not doing an actual bilinear interpolation and only something extremely similar. Thanks, Todd |