by Katja Socher <katja(at)linuxfocus.org>
About the author:
Katja is the German editor of LinuxFocus. She likes Tux,
computer graphics, film & photography, travelling,
Montréal and the sea. Have a look at my newly designed
homepage at http://www.tuxgraphics.org.
Content:
|
Creating panoramic views using Hugin, Enblend and The Gimp
Abstract:
In this article I show you how to create a panoramic picture
using Hugin, Enblend and The Gimp.
_________________ _________________ _________________
|
Creating panoramic views using hugin, enblend and The
Gimp
I have always been impressed when I saw a picture displaying
a panoramic view. Still I don't owe a camera with a panorama
function. But it's not necessary. With Linux all things are
possible and you can create great panoramic views by using
hugin, enblend and The Gimp.
Hugin stitches the pictures together and sometimes what it
produces alone is already satisfying. Most of the time however
you will want to improve the result further. Enblend tries to
make the result more seamless. Finally to give your image the
final touch you manipulate it with the Gimp.
The versions used for this article are hugin 0.4 pre, enblend
1.3 and The Gimp 2.0
Choosing your pictures
Okay, let's see how it works. Here you see a couple of
images of Montréal that were taken from the Mont Royal
sometime in April this year.
I'll tell you the steps I took to get a panoramic picture out
of them so that you can apply this to your own works.
First I created a new directory and sorted the images I wanted
to use in there. This is not really necessary of course but I
find it easier this way. As far as I know you can't sort your
pictures within Hugin but have to add them in the right
order.
You need to choose your images carefully as the quality of the
output image depends very much on them. Make sure that they
were taken from the same distance so that the objects they show
are almost the same size in the different pictures. And of
course the pictures need to overlap at least a little bit (it's
recommended that they overlap at least 20-30%).
Hugin
Okay, after choosing your pictures you start hugin and add
your images under "Images". Click on "Add individual images"
and choose the directory with your images. If you have sorted
them into one directory you can select them all at once by
pressing ctrl while clicking on each picture. Otherwise you can
select them individually. You get a preview of your image if
you select it. This way you can check that you really selected
the right images. Sometimes it is good to select one of the
pictures as an anchor point for position, this will then be
kind of a basis to align the other pictures around this
anchor.
Now you change to "Cameras and Lens". Select one of the
images. In many cases this will fill out the "Design
Parameters" automatically. If not you need to fill in the
"degrees of views" with a number of around 40 (hugin filled
this field with the value 41.112 in my case). This is the
degree of view that most "normal" digital cameras are using.
The lens type usually is "Normal (rectlinear) and the values of
the focal length hugin filled in as 12.48 and the crop factor
as 3.8. That way you have some values in case your camera isn't
detected. If you have a special camera you should consult your
manual or play a bit around with different values.
Next you go to the "Control Points". This is the place where
you spend most of your time. Make sure that you have "auto fine
tune" and "auto add" checked. This way hugin will help you set
the control points correctly and correct them a bit if
necessary.
Now on top you see a list with the image numbers. Select 0 on
the left and 1 on the right to see the first two pictures.
Click on a significant point in the picture on the left, then
look for the same point in the image on the right. If your
second click is out of bounce Hugin will tell you so and you
can reclick. Usually you will need 3 or 4 points. Hugin uses
them to see where the two images overlap. So if it is a
difficult images you may need more control points. After
clicking on those points you get a text like "found
corresponding point, mean xcorr coefficient: 0.987115".
Unfortunately a new point not always improves the value so you
may want to delete a point again by clicking on "delete" below.
For selecting good points for Hugin you should try to select
sharp points and those that have lots of contrast. Also avoid
points too close to the edge and if you have a panorama with
things in the foreground it is said to avoid selecting objects
there to avoid parallax. You can also enlarge the size in which
you view the picture to 100% or more to select the points more
precisely.
Now before continuing with the next pair of images first go to
"Optimizer", let the default "Optimize positions (pairwise...)
as is and click on "Optimize now!". Then return to the "Control
Points" section and repeat the whole procedure (click left on
image 1 and right on image 2 to select the next pair etc.)
until you worked through all the images. After optimizing the
last pair you go to the "Stitcher" section.
Let's start from below. There you need to decide which image
format to use for your output file. If you don't want to use
enblend you can choose jpg, png or tiff. If you want to enhance
your picture with enblend afterwards which will usually be the
case you have to choose "multiple tiff" here. This way you
don't get one finished image but as many pictures as you had
previously given into hugin.
Next you need to choose the Stitching engine. By default the
field says "PTStitcher" but if you haven't installed this
explicitely you need to choose "nona" here.
Click on "Calculate Optimal Size" and on "Calculate Field of
View". You have almost made it.
Before you hit "Stitch now" you only need to decide whether
your output should be a rectilinear, a cylindrical or an
equirectangular. If you only stitch two images together
rectilinear will be the right choice, if you have several
pictures but no 360 degree view cylindrical will probably the
right choice and for an all-around view you choose
equirectangular. The thing is that if you make the wrong
decision here hugin will either stop with an error (if you want
an eqirectangular view while the input is only for rectangular
for example) or the result will look strange (if the result
should be cylindircal while you chose rectilinear for
example).
After clicking in "Stitch now!" hugin asks you to specify an
output file and then starts stitching the images together. This
will take some time so you should go and have a cup of tea
while phoning with your grandmother.
The images you'll get will look similar to this one:
Enblend
Now it's time for Enblend to do its part of the work.
Enblend works directly from the shell so open a shell and
type
enblend -v -o output.tif input1.tif input2.tif...
where output.tif specifies the file you want the result to be
saved in and input1.tif stands for the first image etc.
After hitting return you can pour a second cup of tea and
again phone any of your relatives or maybe even two as this
really takes a long time. Well, of course if you only have 2
pictures it is rather fast but with more pictures this is
really slow. But well, the result is definitively worth
it...
The Gimp
If you look at your image now you already have a panoramic
view. Still you need The Gimp to give your panorama the final
touch. With Hugin and Enblend you usually get a picture with
some empty spaces. If you don't know The Gimp well or don't
want to spend much time you can simply select the part of the
image that has no empty space with the rectangular selection
tool , right click in the image
on Edit-->Copy and then File-->New. A new file opens,
then Edit-->Paste and File-->Save as to save this new
picture.
But often it is also possible to fill the gaps by using the
clone tool in combination with blur . You first apply the clone tool
carefully. It's always good to work on a copy here
(Image-->Duplicate) as you might want to discard your
changes especially if you are not very experienced with this
tool. If you have selected the clone tool you click with your
mouse in the area that is to be cloned while you hold the
Ctrl-key down.Then you release the key and click with the mouse
in the area that you want to paint over. Now you can use the
clone tool the same way you would use a paint brush. Sometimes
you will get a more natural looking picture if you define a new
cloning area several times.
Finally to get rid of the seams that are still there even
though they shouldn't be that big you click on the blur tool
and work with the mouse along the seam until you are satisfied.
Then you can save the picture. Of course it is also possible to
fill in some gaps and cut the rest.
The panorama is ready. If you want you can try to improve the
quality of your image by using the tools I described in my
article
Photo magic with Gimp
Here is the final panorama of Montréal:
Enjoy and create! And as always Happy panoraming!
References
-
The Hugin website is: http://hugin.sourceforge.net/
There you can download Hugin and also find some useful
tutorials.
The installation of hugin is a bit complex because it
depends on a lot of other non standard packages.
The best solution is probably to install one of the
pre-compiled rpm packages from
http://bugbear.blackfish.org.uk/~bruno/panorama-tools/
To use PTStitcher you need the panorama-tools-nonfree
package. Otherwise you can use the nona stitcher.
Those who would like to install from the source will
need the following dependent packages:
- Hugin is a gui frontend for the panotools therefore
you need the panotools tools from
http://panotools.sourceforge.net/ The panotools tools,
also called panorama-tools, have the following
dependencies: jdk-1.3.1 (from www.javasoft.com) and the
following libraries which should be part of most linux
systems: libjpeg libtiff libpng zlib
- wxGTK GUI package http://www.wxwindows.org/
- fftw Fast Fourier Transform library
http://www.fftw.org/
- boost development library http://boost.org/
- vigra computer vision library
http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/
Vigra is needed to build the hugin stitcher 'nona'
Finally you need hugin of course which can be downloaded
at: http://hugin.sourceforge.net/
- Enblend is available at http://www-cad.eecs.berkeley.edu/~mihal/enblend/
You can download enblend there and can also learn more about
how it does what it does.
The installation of enblend is straightforward.
- The Gimp will probably already be installed on your
computer as it is shipped with most distributions. Probably
you have already worked with it lots of time. But anyway, its
webpage is: http://www.gimp.org
- And finally if you are interested in reading more of my
articles you can find them all at my newly redesigned webpage
http://www.tuxgraphics.org
Here you will also find updated versions of this article in
English.
Talkback form for this article
Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers:
2004-10-15, generated by lfparser version 2.50