Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Image rotation and NaNs...
Date: Sat, 6 Jun 2009 10:37:00 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 40
Message-ID: <h0dgsc$5jr$1@fred.mathworks.com>
References: <gvivk5$q0m$1@fred.mathworks.com> <h0dehc$8ui$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1244284620 5755 172.30.248.35 (6 Jun 2009 10:37:00 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 6 Jun 2009 10:37:00 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:545192


"Matman86 Di" <pasqui.squall@email.it> wrote in message <h0dehc$8ui$1@fred.mathworks.com>...
> "Matman86 Di" <pasqui.squall@email.it> wrote in message <gvivk5$q0m$1@fred.mathworks.com>...
> > Hi everybody,I'm trying to rotate an image but,for some reason,when I make a 360? rotation I can't get the original image,but I got some NaNs too in image matrix and I don't know why...here is the code:
> > 
> > [M N]=size(X);
> > [n m]=meshgrid(-N/2:N/2-1,-M/2:M/2-1);
> > np=n*cos(2*pi)-m*sin(2*pi);
> > mp=n*sin(2*pi)+m*cos(2*pi);
> > y=interp2(n,m,X,np,mp,'linear'); 
> > 
> > Thx in advance...
> 
> Anyone??T_T

well, yes: your results comply exactly with the rule...

     help interp2;
%{
% note: EXTRAPVAL
...
    ZI = INTERP2(...,METHOD,EXTRAPVAL) specificies a method and a scalar 
    value for ZI outside of the domain created by X and Y.  Thus, ZI will
    equal EXTRAPVAL for any value of YI or XI which is not spanned by Y 
    or X respectively. A method must be specified for EXTRAPVAL to be used,
    the default method is 'linear'.
...
%}
% eg,
     X=magic(3);
     [M N]=size(X);
     [n m]=meshgrid(-N/2:N/2-1,-M/2:M/2-1);
     np=n*cos(2*pi)-m*sin(2*pi);
     mp=n*sin(2*pi)+m*cos(2*pi);
     y=interp2(n,m,X,np,mp,'linear');
% look at
     [n;nan(1,size(n,1));np]     % <- nan: separator...
% -or-
     [m;nan(1,size(m,1));mp]

us