Thursday, November 22, 2007

Cartoon Castle and Flowers


Cartoon Castle and Flowers
Originally uploaded by Seb Przd
Flash 9 version, made with the trial version of Pano2VR.

Sunday, October 21, 2007

Building Hugin in Ubuntu (Feisty Fawn and Edgy Eft)

This is a work-in-progress as I figure out what are the necessary steps one has to take to go from a scratch installation of Ubuntu (or Kubuntu, or Xubuntu) to a building environment for source packages of hugin and its related tools (autopano-sift-c, libpano13, enblend). This has been tested in Kubuntu Edgy Eft and Feisty Fawn, but of course no installation is ever the same and I would welcome your comments as to what packages you had to install, or what error messages you are facing.

About hugin
Hugin is a very versatile software to merge different photos into panoramas. It is open source and its development is quite active so people might benefit from building from the sources. This post is part of a recent push to try to get frequent builds in most operating systems (Linux, Mac OSX and Windows).

Basic setup

Installation of needed components. This is the most difficult part, since once you have all the components you will be able to build hugin as often as you want.
  1. Subversion
    sudo apt-get install subversion
  2. Install cmake, other building tools and other libraries
    sudo apt-get install cmake checkinstall
    sudo apt-get install libvips10-dev libvips10c2a libgcj7-0 libgcj7-dev
    Here is the list as I could work it out from objdump -p /usr/local/bin hugin. Some sound strange, probably because I am building in 64bit linux.
    sudo apt-get install ia32-libs lib32gcc1 lib32stdc++6 lib32z1 \
    libc6 libc6-i386 libgcc1 \
    libjpeg62 libopenexr2c2a libpng12-0 libstdc++6 libtiff4 \
    libwxbase2.6-0 libwxgtk2.6-0 zlib1g \
    lib32gcc1 libstdc++6-dev lib32z1-dev \
    libc6-dev libc6-i386-dev libgcc1-dev \
    libjpeg62-dev libopenexr2c2a-dev libpng12-0-dev libstdc++6-dev libtiff4-dev \
    libwxbase2.6-0-dev libwxgtk2.6-0-dev zlib1g-de

Building libpano13

  1. Download the source from SVN
    svn co https://panotools.svn.sourceforge.net/svnroot/panotools/trunk/libpano libpano13
    cd libpano13
    ./bootstrap
    Check if dependencies are missing; install and relaunch the configure process
    ./configure
  2. Compile and install
    make
    sudo checkinstall

Building hugin

  1. This is the trunk, which has been updated now from the Ippei branch:
    svn co https://hugin.svn.sourceforge.net/svnroot/hugin/hugin/trunk/ hugin
  2. Building hugin: there is only one procedure right now with cmake
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local .
    make
    sudo checkinstall
    Sometimes when launching hugin it gives an error that a library is impossible to load. You have to run:
    sudo ldconfig

Monday, September 24, 2007

Slice of Menger sponge


Slice of Menger
Originally uploaded by Seb Przd
What happens when you slice a Menger Sponge diagonally through the center? well, a very interesting pattern of stars and hexagons. This is the level four iteration on the Menger sponge.

I haven't seen this mentioned before on the internet. Maybe a reader will know if these intersections of the Menger Sponge have been studied before? Wolfram mentions that:
The Menger sponge, in addition to being a fractal, is also a super-object for all compact one-dimensional objects, i.e., the topological equivalent of all one-dimensional objects can be found in a Menger sponge (Peitgen et al. 1992).

Sunday, September 9, 2007

Zenith bug in Enblend 3.0, some progress

Ever since version 3.0 of enblend was introduced, there has been an annoying bug with the way the zenith is blended (and also, it seems on some vertical lines). Development of enblend is not very transparent, and it is not very clear whether this bug has been acknowledged by the developer. So here is my attempt to explain a bit more what is happening and give the repeatable conditions under which the bug is apparent.

The source files, as produced by hugin, are here. They are numbered from 0 to 9, 0 is the nadir (the floor), 1 is the zenith (the sky) and 2 to 9 are the horizon images.

Here is an example of what the bug looks like: a nasty grey line in the top of the image.

This can be corrected by loading on top of this image the tif file of the zenith, and replacing the top part of the image. But it is a pain in the mouse to do this every time.

What I've found is that the order of loading the images is important for this bug to appear. I used to blend in order 2 to 9, 0 and 1, since this stitches first the horizon row of images. But if the zenith is the first image loaded (so the images are stitched 1 to 9 and 0) the resulting image looks like this:

i.e., a trouble free image. I tried other permutations of the images, and if the zenith is "blended" unto another image the bug appears (e.g., if the images are blended 2, 1, 3 to 9 and 0). However if 0 and 1 are loaded first, since they do not overlap they are not blended, and the bug in the zenith does not appear.

Thursday, September 6, 2007

Multiplane Perspective in MathMap

Four rectilinear projections with carefully selected field-of-views to produce a 360° panorama without corners (almost). You have to view the original panorama to compare.


There are other "multiplane perspective" panoramas, loosely inspired by this paper.
Here is the script to be used in MathMap.

How to use this script

  1. Load a suitable equirectangular image in Gimp (with four walls in a rectangle - this script does not cover trapezoidal rooms)
  2. Open the MathMap plug-in
  3. Copy & paste the code that you will find below
  4. Select "Wrap" in the settings
  5. In the User values, change lambda0 until a corner of the room in your panorama is at the border of the image.
  6. Still in the User values, change t3 until the leftmost wall is exactly covered by
    the first rectilinear projection
  7. Change t2 until the second leftmost wall is covered exactly by the second rectilinear
    projection
  8. Finally, change t3 until the last corner of the room is split between the last two
    rectilinear projections
  9. Change size (the vertical field of view) and yshift until the image looks fine
  10. Press OK, wait, and save.

#####################################################
# Four rectilinear projections covering 360° #
# Mathmap script by Seb Przd (2007) #
# http://flickr.com/photos/sbprzd #
# Licensed under the GPLv3 #
#####################################################
filter fourrectilinear (image in,float size: 1-2 (1),
float lambda0:-1-1 (0),float yshift:-1-1(0),float t3:
0-1(0.5),float t2:0-1(0.5),float t1:0-1(0.5))
il=0.01;ir=0.99;epsl=-100;epsr=100;iter=0;eps=1;while
(abs(eps)>0.0001)&&(iter<20) do xu=(il+ir)/2;tt1=tan(
pi/2-t1*pi)/2; tt3=tan(pi/2-t3*pi);yu=tt1+sqrt(xu*(1-
xu)+tt1^2); llmyy=tt3+sqrt(xu*(1-xu)+tt3^2);ll=llmyy+
yu;eps=tan(pi/2-t2*pi)-(-yu*llmyy+(1-xu)^2)/(ll*(1-xu
));if eps*epsl<0 then ir=xu;epsr=eps;else il=xu;epsl=
eps;end;iter=iter+1;end;l2=(1-xu)/(1+ll);l4=xu/(1+ll)
;l1=llmyy/(1+ll);l3=yu/(1+ll);xmvec=[-1,-1+l2+l4,0,l2
+l4,1]; xcvec=[-1+l4,-l3,l2,1-l1];lvec=[l1,l2,l3,l4];
lpv=[-3,-1,1,3]*pi/4+atan(l4,l1);xx=x*size;yy=y*size;
co=0; while co<=3 do xc=xcvec[co];xt=xx-xc*X;yt=yy-X*
yshift;if xx<=xmvec[co+1]*X&&xx>= xmvec[co]*X then lp
=lpv[co]; x0=xt;y0=yt;lc=lvec[co];end;co=co+1;end;rr=
sqrt(x0^2+y0^2);c=atan(rr/Y/2/lc);phi=asin(y0*sin(c)/
rr);in(xy:[atan(x0*tan(c),rr)*X/pi+lp*X/pi+lambda0*X,
phi*Y/(pi/2)]) end

Saturday, August 25, 2007

How to build the Fujimoto Origami Cube

Cut and Fold If you've been following my stream on flickr you will have seen a pattern to be folded into a cube, with a panorama printed on it so you get a "Virtual Reality Cube". The pattern looks like this (click on it to go the flickr page where you can download a large version of it). Here are the instructions to fold this cube created by Shuzo Fujimoto. You will need to refer to the pattern of folds to help you know what you need to fold. In fact, this pattern (on the upper right part of the picture) could be sufficient to let you know how to fold it, but one of the steps is tricky. You can find hand-drawn instructions.


Print and cut the square.
Fold in half, and keep folded.
Fold again in half.
Unfold the top part.
Fold down the middle.
Fold then one of the halves...
... and the other.
Unfold everything. We have all the straight line creases marked.
Fold the slanted lines, as in the pattern. Not pictured here: you have to do that 8 times in all.All the creases have been made now. It should look like this.
Now turn it around.
This is the hardest part. With your thumb and fingers, press the bottom third square from the left upwards and to the left.If all the pre-creases are correct, it should fold itself quite easily. If not, straighten them again and push...
... and push, putting the four folds in the correct position.
Fold the fourth corner below the first one to get the top of the cube to lock.Turn over and start folding the four flaps, one after the other.
When you come to the last one, fold it below the first one, and......voilĂ  !

Friday, August 17, 2007

I wish I had thought of that with my kids

Another way of doing a Droste with your children!

Monday, August 13, 2007

Conformal Cube: The Story of a Search

What you see here is the result of a long and complicated search, but with an enormous amount of help from Daniel M. German I've able to construct the conformal projection of the cube. If your first reaction is to mutter: "The what of the cube?" or just "So?", and if you are interested, please follow these explanations...

You may have seen before panoramas projected in a cube: in flickr for example, there is a "foldables" group and I have some myself (including other polyhedra). These panoramas have all in common the use of the gnomonic or perspective projection: in this type of projection straight lines stay straight. This is great for architectural photos, but as you can see for the model on the right, you get broken lines in the sides of the cube (the columns of the cathedral seem to be broken).

It is possible in theory to devise a conformal projection that would show the sphere as a cube. However it is very difficult to find information on such a projection. The usual internet cartography sources, if they mention this projection, give no clue at all how it can be constructed. The only reference is in this PDF file where a planisphere projected conformally in the cube is given, only quoting John Parr Snyder's personal software. John Parr Snyder is the most precious reference for mathematical cartography available on the web, and though he died in 1997 his personal BASIC program used to generate maps is the only trace left of how he constructed the conformal cube... mostly undocumented, and of course not portable at all. Furthermore, the formulas used in that program are all forward transformations, whereas the projection of an image needs the inverse formulas.

But a reference was there! a 1976 paper in Cartographica titled "Conformal Projections based on Elliptic Functions" by L.P. Lee (another incredibly talented cartographer, "who retired in 1974 as Chief Computer in the New Zealand Department of Lands and Survey") seemed to be the source for these polyhedral globes. Daniel German was very very helpful in locating this rather obscure publication (and others), and I have to thank him for that!

The conformal projection uses an incredible 1872 theorem by Hermann Schwarz who showed that "the spherical triangles into which the surface of the sphere is divided by the planes of symmetry of the regular polyhedra can be conformally represented on the infinite half-plane by algebraic transformations of the stereographic projection on the central plane so that the vertices are represented by the points 0, 1, infinity on the real axis". Unfortunately the paper is in german and is probably even harder to get, so I will able to look how Schwarz showed this...

(the source image for this shot is from the Notre-Dame-de-Reims Cathedral in Reims, France)

Saturday, August 11, 2007

Edit the Nadir and Zenith of an Equirectangular Panorama

Often the most difficult part of an equirectangular panorama (360° wide, 180° vertically) is the nadir, i.e. the bottom. This is where the tripod is, so no clear shot can be had without some sort of acrobatics to tilt the tripod away. So an important part of creating a nice equirectangular panorama is editing the nadir (and sometimes, the zenith).
The procedure I had been using so far is:
  1. Create the equirectangular image (in Gimp)
  2. Use hugin to create the rectilinear projection of the nadir, with a 90° field-of-view
  3. Edit this rectilinear image (in Gimp)
  4. Use hugin to output this edited rectilinear image into an equirectangular panorama
  5. Manually blend the extra nadir unto the equirectangular image (in Gimp).
As you can see, this needs going back and forth between Gimp and hugin, and is not very practical. Spurred by the Photoshop tool mentioned here I bring to you a Gimp/Mathmap script to create the zenith and nadir of an equirectangular panorama, edit in place and transform back.

You should first make a copy of the layer with the equirectangular image, since the transformation to and back from the zenith/nadir does not keep the part around the horizon.

Filter used to create the Zenith and Nadir:

filter ToNadirZenith (image in)
# Filter created by Seb Przd
# Licensed under the GPL

if x<0 then
sinphi1=1;
xx=x+X/2;
else
sinphi1=-1;
xx=x-X/2;
end;

yy=y;

rr=sqrt(xx^2+yy^2);

c=atan(rr/Y);

phi =
if rr == 0 then
0
else
asin(cos(c)*sinphi1)
end;

xxx=atan(xx,-yy*sinphi1)*X/pi;
yyy=phi*Y/(pi/2);

in(xy:[xxx,yyy])
end


Filter used to transform back the Zenith and Nadir:

filter FromNadirZenith (image in)
# Filter created by Seb Przd
# Licensed under the GPL

output=1;
if y>Y/4 then
sinphi1=1;
xc=-X/2;
else if y<-Y/4 then
sinphi1=-1;
xc=X/2;
else
output=0;
end;
end;

cosc=sinphi1*sin(y/Y*pi/2);
xx=cos(y/Y*pi/2)*sin(x/X*pi)/cosc;
yy=-sinphi1*cos(y/Y*pi/2)*cos(x/X*pi)/cosc;

if abs(xx)>1 then output=0; end;

if output then
in(xy:[xx*X/2+xc,yy*Y])
else
rgbaColor(0,0,0,0)
end

end

Tuesday, July 3, 2007

Miniville: The SimCity of the 2000s


Miniville
Originally uploaded by seb przd
You liked to play SimCity when you were young(er)... now let the others play it for you. It seems that every time somebody clicks on the link for a city, the population increases by one, or something else happens: you get links for the environment, industry, transportation, etc. So it's like SimBlogCity...

(if anybody is still reading this blog, go ahead and click! don't be afraid! may be the Schwarz be with you!)