From: Justus P. <Jus...@UL...> - 2005-02-22 12:09:57
|
Paul, Paul Kienzle <pki...@us...> wrote on Sat, 19 Feb 2005 15:47:00 -0500: > Here are some more tests you might include: > > % Make sure the dithering preserves pixel density > t=3Dzeros(1,5); > for n=3D1:15; t(n) =3D sum(imrotate(eye(n),20,'bilinear')(:)); end > assert(t,[1:15]); This test in fact works. The only difference is that my code always produces a slightly smaller sum because it does not pad the image (see my previous message for a brief discussion). With growing image sizes and fixed rotation angle, the difference is bounded: assert(t,[1:n], 2.2) should pass for any n. > % Make sure the size matches the expected size assuming square pixels. > angle=3D20; t=3Dzeros(15,2); > for n=3D1:15; t(n,:) =3D size(imrotate(ones(n,3*n),angle,'bilinear'));= end > a =3D angle*pi/180; > x =3D ceil([(1:n);3*(1:n)]'*[cos(a) sin(a);sin(a) cos(a)]); > assert(t,x); If you insist... the code for computing the image size is trivial. But to be fair, use round() because this is what imrotate does. In that case, a tolerance of 1 is sufficient to pass the assert(), except for the very first element. But I really would not include this test. It is only a rough estimate, the code in imrotate is at least as simple and does it better. 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 |