From: Paul K. <pki...@us...> - 2005-02-19 20:47:09
|
Yes, imrotate seems to be broken for all of bilinear, bicubic and nearest. As Todd pointed out, 'nearest' is particularly glaring. Can the users of this function please come up with a fix which you are all happy with? Here are some more tests you might include: % Make sure the dithering preserves pixel density t=zeros(1,5); for n=1:15; t(n) = sum(imrotate(eye(n),20,'bilinear')(:)); end assert(t,[1:15]); % Make sure the size matches the expected size assuming square pixels. angle=20; t=zeros(15,2); for n=1:15; t(n,:) = size(imrotate(ones(n,3*n),angle,'bilinear')); end a = angle*pi/180; x = ceil([(1:n);3*(1:n)]'*[cos(a) sin(a);sin(a) cos(a)]); assert(t,x); Thanks, - Paul On Feb 19, 2005, at 2:55 PM, Jeff Orchard wrote: > > I'm not sure the bilinear option is working. > > imrotate(eye(13),45,"bilinear") > > and > > imrotate(eye(13),40,"bilinear") > > Jeff > > > On Feb 16, 2005, at 12:48 AM, Todd Neal wrote: > >> On Tue, 15 Feb 2005 23:58:04 -0500, Paul Kienzle >> <pki...@us...> wrote: >>> I replaced the old version of imrotate with what you sent. >>> >>> 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 = rand(30); >>> Y = imrotate(imrotate(X,30,'bicubic'),-30,'bicubic'); >>> norm(X(17+[1:5],17+[1:5])-Y(30+[1:5],30+[1:5])) >>> ans = 0.46103 >>> >>> Using a smoother function worked better: >>> >>> X = peaks(30); >>> Y = imrotate(imrotate(X,30,'bicubic'),-30,'bicubic'); >>> norm(X(17+[1:5],17+[1:5])-Y(30+[1:5],30+[1:5])) >>> ans = 0.0036647 >>> >>> Anyone have any better suggestions? >>> >> >> I was looking for a few good test cases and came across using this as >> a test case: >> >> imrotate(eye(20),45) >> >> The problem is displayed here (in a smaller case to fit in an email >> well): >> >> octave:18> imrotate(eye(13),45) >> ans = >> >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 >> 1 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 1 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> >> >> Todd > |