EquiRectangular Projection Help

489 views
Skip to first unread message

Dan

unread,
Feb 14, 2012, 8:33:49 AM2/14/12
to hugin and other free panoramic software
Hello everyone,

I am new to this group and this is my first post. I am in a way of
learning and knowing more about panoramas and its process since last
whole year. I have gone through almost all tutorials (including
panotools and hugin's) and many other papers on google and those on
other universities's site. But till date, I am not able to find the
exact foumullas to stitch images in to an equirectangular pano. 6
months ago, I was limited to only cylindrical and partial spherical
projections. But as I came across the full view 360x180
equirectangular one, it seemed interesting to me(a lot, in fact). But
let me very frank, since those last 6 months, I have been stuck on
that only. I tried searching everywhere, but I didn't find "HOW TO
ACTUALLY MAKE IT". Then I looked at panotools. The source has some
methods of generation of an equi panorama. I tried understanding it
many times, but still i am not getting it.

Can anyone here, show or point me exactly to that part in code which
applies distortion on equirectangular pano. This has nothing to do
with the stitching part. Just projection is involved.

The tutorials online and most other documents don't actually go deep
in to it. Can anybody help?

dmg

unread,
Feb 14, 2012, 11:41:58 AM2/14/12
to hugi...@googlegroups.com
On Tue, Feb 14, 2012 at 2:33 AM, Dan <dans...@gmail.com> wrote:
> Hello everyone,
>
> I am new to this group and this is my first post. I am in a way of
> learning and knowing more about panoramas and its process since last
> whole year. I have gone through almost all tutorials (including
> panotools and hugin's) and many other papers on google and those on
> other universities's site. But till date, I am not able to find the
> exact foumullas to stitch images in to an equirectangular pano. 6
> months ago, I was limited to only cylindrical and partial spherical
> projections. But as I came across the full view 360x180
> equirectangular one, it seemed interesting to me(a lot, in fact). But
> let me very frank, since those last 6 months, I have been stuck on
> that only. I tried searching everywhere, but I didn't find "HOW TO
> ACTUALLY MAKE IT". Then I looked at panotools. The source has some
> methods of generation of an equi panorama. I tried understanding it
> many times, but still i am not getting it.

Are you interested in creating the panorama or the software that
creates the panorama?

--dmg

> Can anyone here, show or point me exactly to that part in code which
> applies distortion on equirectangular pano. This has nothing to do
> with the stitching part. Just projection is involved.
>
> The tutorials online and most other documents don't actually go deep
> in to it. Can anybody help?
>

> --
> You received this message because you are subscribed to the Google Groups "Hugin and other free panoramic software" group.
> A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
> To post to this group, send email to hugi...@googlegroups.com
> To unsubscribe from this group, send email to hugin-ptx+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/hugin-ptx

--
--dmg

---
Daniel M. German
http://turingmachine.org

Dan

unread,
Feb 14, 2012, 12:25:33 PM2/14/12
to hugin and other free panoramic software
in the software that creates the panorama

On Feb 14, 9:41 pm, dmg <d...@uvic.ca> wrote:
> > For more options, visit this group athttp://groups.google.com/group/hugin-ptx

kfj

unread,
Feb 14, 2012, 12:55:58 PM2/14/12
to hugin and other free panoramic software


On 14 Feb., 18:25, Dan <dansut...@gmail.com> wrote:
> in the software that creates the panorama

The code which does the transformations is in libpano. First you have
to get a checkout of the code from their repository. Then you have to
look into the file math.c. The routines from where you can find your
way down are 'execute_stack' and 'execute_stack_new'.

The transform is a rather complicated sequence of separate partial
transforms, including translations, rotations and more involved stuff.
These are modelled as individual functions which are put onto a stack,
which is, later on, executed for every target pixel in the warped
image. The execution of the transformation stack is done inside the
warping routine, and once the source location needed for the target
pixel has been determined, it's interpolated from the source image and
written to the target. Then the same is done for the next target pixel
and so on. I wish there was proper documentation for this - I have had
to work it out from the sources myself. If you want to just play with
the transform and not dig into the C code, you can use the utility
program pano_trafo which comes with hugin, and if you have a python-
enabled hugin, you can use the transforms in python as well.

Kay

dmg

unread,
Feb 14, 2012, 3:46:57 PM2/14/12
to hugi...@googlegroups.com

The only thing that I would add to Kay detailed response is that the
equirectangular
is a very special type of projection in libpano. It is sort of the
intermediary projection
between fisheye or rectilinear and most projections. This is partially
because it
has the property x = \lamba and y = \phi

--dmg


>
> Kay


>
> --
> You received this message because you are subscribed to the Google Groups "Hugin and other free panoramic software" group.
> A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
> To post to this group, send email to hugi...@googlegroups.com
> To unsubscribe from this group, send email to hugin-ptx+...@googlegroups.com

> For more options, visit this group at http://groups.google.com/group/hugin-ptx

Dhaval S

unread,
Feb 14, 2012, 9:44:27 PM2/14/12
to hugi...@googlegroups.com
The code which does the transformations is in libpano. First you have
to get a checkout of the code from their repository. Then you have to
look into the file math.c. The routines from where you can find your
way down are 'execute_stack' and 'execute_stack_new'. 

Ya, i have checked both routines, the functions in math.c and also those in remap.c. As you told the transformation is rather complicated one(even i fear the same looking at the code), I was not able to locate the only piece that does what i need. 

and ya, I too feel the same of digging in to sources only when it comes to understanding something with libpano. Why didn't they built a documentation? I tried even searching on google if anyone else has written but failed. Meanwhile let me try looking at pano_trafo.

Dhaval S

unread,
Feb 14, 2012, 9:45:52 PM2/14/12
to hugi...@googlegroups.com
ya, is it so that libpano is converting all coordinates to spherical first then processes them, and at the end converts back them to what is required by the projection ?

kfj

unread,
Feb 15, 2012, 5:31:54 AM2/15/12
to hugin and other free panoramic software


On 15 Feb., 03:45, Dhaval S <dansut...@gmail.com> wrote:
> ya, is it so that libpano is converting all coordinates to spherical first
> then processes them, and at the end converts back them to what is required
> by the projection ?

Yes. The coordinates are actually converted into 3D real-worls
coordinates, so that the extrinsic transformation (yaw, pitch, roll)
can be performed. So, since you start out with target coordinates,
first it's target projection to spherical, then rotate, then spherical
to source image projection, then the intrinsic transformations - lens
type (rectilinear, fisheye etc.), lens correction. Finally you arrive
at the location in the source image to look at and get the data from.

Kay

Dan

unread,
Feb 15, 2012, 8:30:33 AM2/15/12
to hugin and other free panoramic software
Exactly. But, think the case where I am my self providing the
theta,phi of the center pixel of image (or some people say sight of an
image), then how would i find those for rest of pixels?

kfj

unread,
Feb 16, 2012, 3:33:51 AM2/16/12
to hugin and other free panoramic software


On 15 Feb., 14:30, Dan <dansut...@gmail.com> wrote:
> Exactly. But, think the case where I am my self providing the
> theta,phi of the center pixel of image (or some people say sight of an
> image), then how would i find those for rest of pixels?

I don't follow your argument. Please make sure when talking about
'image', whether you are refering to the source image (i.e. the photo
you are processing) or the target image (i.e. the 'warped' image you
want to make which is to be blended into your panorama)

If you want to start from source image coordinates (which is what I
guess you mean), you need a forward transform, doing first the
intrinsics, then the rotations and then the transformation into the
target projection. This route is not usually taken (there are
exceptions, tough). The usual method is an inverse transform from
target coordinates to source coordinates. Try and play with
pano_trafo, and you'll get a feel for it.

Kay

Dan

unread,
Feb 16, 2012, 12:56:47 PM2/16/12
to hugin and other free panoramic software
sorry,,i forgot to mention that I was talking about forward transform
and the image was the source image. and most of time they do inverse
transform. I just went for forward just to understand. It should work
atleast (even if it leaves some pixels blank, thats not the concern
right now), I dont want to go for interpolation. Thing is just it
should work, quality i will check later on.  I was reading the source
code of libpano and stuck again. Can you tell me what these lines are
doing in math.c of libpano library ?

what is sphere_tp_erect doing? and these lines in it? ::

phi = x_dest / distanceparam;
theta =  - y_dest / distanceparam  + PI / 2;
if(theta < 0)
{
theta = - theta;
phi += PI;
}
if(theta > PI)
{
theta = PI - (theta - PI);
phi += PI;
}

s = sin( theta );
v[0] =  s * sin( phi ); //  y' -> x // sin(theta)*sin(phi)
v[1] =  cos( theta ); //  z' -> y // cos(theta)

r = sqrt( v[1]*v[1] + v[0]*v[0]);
theta = distanceparam * atan2( r , s * cos( phi ) );

*x_src =  theta * v[0] / r;
*y_src =  theta * v[1] / r;


Where do these formulas come from? Isn't there atleast some
documentation of this libpano anywhere ???
Message has been deleted

kfj

unread,
Feb 17, 2012, 4:22:27 PM2/17/12
to hugin and other free panoramic software


On 16 Feb., 18:56, Dan <dansut...@gmail.com> wrote:
> sorry,,i forgot to mention that I was talking about forward transform
> and the image was the source image. and most of time they do inverse
> transform. I just went for forward just to understand. It should work
> atleast (even if it leaves some pixels blank, thats not the concern
> right now), I dont want to go for interpolation. Thing is just it
> should work, quality i will check later on.  I was reading the source
> code of libpano and stuck again. Can you tell me what these lines are
> doing in math.c of libpano library ?
>
> what is sphere_tp_erect doing?

sphere_to_erect converts from spherical coordinates to equirectangular
projection, says it's name - and that's about all I know.

> and these lines in it? ::

> phi     = x_dest / distanceparam;
>         theta   =  - y_dest / distanceparam  + PI / 2;
>         if(theta < 0)
>         {
>                 theta = - theta;
>                 phi += PI;
>         }
>         if(theta > PI)
>         {
>                 theta = PI - (theta - PI);
>                 phi += PI;
>         }
>
>         s = sin( theta );
>         v[0] =  s * sin( phi );        //  y' -> x // sin(theta)*sin(phi)
>         v[1] =  cos( theta );                          //  z' -> y // cos(theta)
>
>         r = sqrt( v[1]*v[1] + v[0]*v[0]);
>        theta = distanceparam * atan2( r , s * cos( phi ) );
>
>         *x_src =  theta * v[0] / r;
>         *y_src =  theta * v[1] / r;

... I fear you'll have to figure it out yourself. I suppose it's
reasonably sraightforword trigonometry, but I haven't looked into the
details - I'm more interested in using the transforms than
understanding their inner workings, so I can't really help you there.

> Where do these formulas come from? Isn't there atleast some
> documentation of this libpano anywhere ???

you'll have to do some research. Try

http://wiki.panotools.org/Projection

for starters and see where it takes you. It's a complex topic. Trying
to figure out libpano isn't for the fainthearted. If you want it
simple and well-documented, this is probably not where you want to
look. Best of luck

Kay

Dan

unread,
Feb 19, 2012, 9:01:17 AM2/19/12
to hugin and other free panoramic software
thanks for helping
Reply all
Reply to author
Forward
0 new messages