Loading ...
Sorry, an error occurred while loading the content.

Fw: Fw: [PanoToolsNG] stereographic projection in MatLab

Expand Messages
  • Gerald Lodron
    no problem but as I already mentioned it is only a polartransformation and no stereographic one. I think they called it wrong at the link seb gave me (or my
    Message 1 of 1 , Apr 29, 2009
      no problem but as I already mentioned it is only a polartransformation and no stereographic one. I think they called it wrong at the link seb gave me (or my implementation is wrong). There is already an implementation at mathworks: http://www.mathworks.com/matlabcentral/fileexchange/17933%c2%a0but if you prefer my code (you will need image processing toolbox in your matlab installation but my code has implemented the bicubic interpolation):

      Save following in a m file called stereographic.m:

      function    zeta=-sin(isTForm.tdata.warp)*1+cos(isTForm.tdata.warp);
          r = sqrt((imPtsIn(:,2)-isTForm.tdata.vSizeOut(2)/2).^2+(imPtsIn(:,1)-isTForm.tdata.vSizeOut(1)/2).^2);
          a = atan2((imPtsIn(:,1)-isTForm.tdata.vSizeOut(1)/2),(imPtsIn(:,2)-isTForm.tdata.vSizeOut(2)/2));
          colat=2.*atan2(rho,radius);    %colat=2.*atan(rho./radius);    long=mod(a+2*pi*isTForm.tdata.turn,2*pi);
          imPtsOut(:,1)=isTForm.tdata.offset+(isTForm.tdata.vSizeIn(1)-1)*long/pi;imPtsOut = stereographic(imPtsIn, isTForm)

      And then write following in the console:


      tdata.turn = 0;
      tdata.zoom = 1;
      tdata.sc = 1;
      tdata.warp = pi;
      tdata.vSizeIn = size(I);
      tdata.vSizeOut = [2*size(I,1), 2*size(I,1)]';
      tdata.offset = 4;
      A=zeros(size(I,1), size(I,2)+8,3,class(I));
      A(:,1:4,:) = I(:,end-3:end,:);
      A(:,5:end-4,:) = I;
      A(:,end-3:end,:) = I(:,1:4,:);
      TFORM = maketform(
      O = imtransform(A, TFORM, 'custom', 2, 2,[],@stereographic, tdata);'cubic', 'XData', [1 tdata.vSizeOut(1)], 'YData', [1 tdata.vSizeOut(2)]);

       If anyone sees an error please post it. If I will have a real stereographic projection solved I will post it on mathworks but I dont want to upload things which does not work (and polartransformations are already on mathworks).

      best regards,

      ----- Forwarded Message ----
      From: pedro_silva58 <pedro_silva58@...>
      To: PanoToolsNG@yahoogroups.com
      Sent: Wednesday, April 29, 2009 10:29:25 AM
      Subject: Re: Fw: [PanoToolsNG] stereographic projection in MatLab

      now that it works, thanx to seb's assistance, are you willing to share the matlab code back into the community? might make it easier for somebody else to change the formulas for other transformations. ..

      --- In PanoToolsNG@ yahoogroups. com, Gerald Lodron <gerald.lodron@ ...> wrote:
      > Now it works but the formular is only a polar coordinate transform and NOT a stereographic projection, lol
      > ----- Forwarded Message ----
      > From: Seb Perez-D <sbprzd@...>
      > To: gerald.lodron@ ...
      > Sent: Tuesday, April 28, 2009 9:07:01 AM
      > Subject: Re: [PanoToolsNG] stereographic projection in MatLab
      > On Tue, Apr 28, 2009 at 09:00, Gerald Lodron <gerald.lodron@ ...> wrote:
      > >
      > >
      > > Ok, I will try it but there are a few parameters missing:
      > > long=(a+2*pi* turn)
      > > What is the parameter a and what is the symbol % stand for?
      > >  in(xy:[nx,ny* zeta])
      > >
      > > I think in is the in is the input image but i do not understand the whole
      > > line with the : and the [] oberator!
      > a is the angle (theta) = atan2(y,x)
      > in is the source image, in(xy:[u,v]) takes the pixel with coordinates (u,v)
      > % is the modulus operator
      > [Non-text portions of this message have been removed]

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.