From: Justus P. <Jus...@UL...> - 2005-02-16 10:08:58
|
> I would appreciate a few simple test cases which do not > rely on a human visual system to determine if the result > is correct. > > I tried the following: > > X =3D rand(30); > Y =3D imrotate(imrotate(X,30,'bicubic'),-30,'bicubic'); > norm(X(17+[1:5],17+[1:5])-Y(30+[1:5],30+[1:5])) > ans =3D 0.46103 Yes, for random images there's no hope... > Using a smoother function worked better: > > X =3D peaks(30); > Y =3D imrotate(imrotate(X,30,'bicubic'),-30,'bicubic'); > norm(X(17+[1:5],17+[1:5])-Y(30+[1:5],30+[1:5])) > ans =3D 0.0036647 I like this. I suggest to use "crop", this saves indexing adjustments and makes the code more transparent and robust to future changes to the size of the rotated image. Moreover, Fourier does not seem to handle negative pixel values: X =3D peaks(30); X -=3D min(min(X)); Y =3D imrotate(imrotate(X, 30, "bicubic", "crop"), -30, "bicubic", "crop"= ); norm(X(10:20,10:20) - Y(10:20,10:20)) ans =3D 0.076178 This can now be used with all four interpolation methods. As a complementary test of the "nearest" method, I suggest to compare near-90-degree rotations to exact 90-degree rotations (only the latter are handled by rot90, with greetings to Todd!). For odd image sizes, the result should be exact: X =3D rand(99); Y =3D imrotate(X, 89.9, "nearest"); Z =3D imrotate(Y, -89.9, "nearest"); norm(X-Z) ans =3D 0 norm(Y - imrotate(X, 90, "nearest")) ans =3D 0 Also try 90.1 degrees, and likewise around 180 and 270. I think it would be useful to add these test cases to imrotate.m. 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 |