[c28c78]: tutorials / Blend-masks / en.shtml~  Maximize  Restore  History

Download this file

235 lines (227 with data), 12.1 kB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /><title>Hugin tutorial &#8212; Blend masks</title>

  <style media="screen" type="text/css" title="Screen style sheet">
@import url(../../css/normal.css);
  <link rel="icon" href="../../css/icon.png" type="image/png" /></head><body>
<!--#include virtual="/ssi/menu.shtml"-->
<div class="content">
<h1>Hugin tutorial &#8212; Blend masks<br />
<p><strong>This tutorial covers an advanced use of Hugin &#8212; Using masks
to control the blending of images within the overlap region.</strong></p>
<p>Note: This tutorial is based on the 2010.2 version of Hugin. If you have a later version of Hugin which supports blend masks,
some of the detail may differ, but the underlying principle will remain
same.<br />
There are times when the blending of photos gives an
result, such that the blend region shows artifacts that would not
be seen if an area from another overlapping photo had been used instead.<br />
The problem is often noticeable when the photos contain people. A
person may be walking and appear multiple times in a series of photos,
or appear only in part
in the stitch.<br />
Blend masking allows you to define an <span style="font-weight: bold;">Include
region</span> which the blender will try to incorporate into the final
stitch, or to define an <span style="font-weight: bold;">Exclude region</span>
which the blender will try to keep out of the stitch.<br />
The <span style="font-weight: bold;">Mask</span> tab in the main Hugin
window allows
you to select the image in which you want to define a mask; define the
mask as a closed polygon by selecting points with the mouse; change a
mask from exclude to include region, and <span style="font-weight: bold;">Save</span>, <span style="font-weight: bold;">Load</span> or <span style="font-weight: bold;">Delete</span> a mask.<br />
Blend masks are not like your normal 'cut out' and 'paste in' masking.
They are more like giving hints to the blender, so it isn't always
necessary to carefully define a mask exactly on the boundary of an
object. Often it sufficient to only roughly enclose the object to be
included or excluded.<br />
<p>You can download the photos used in this tutorial to try it
yourself. <a href="p1020257.jpg">p1020257.jpg</a> <a href="p1020258.jpg">p1020258.jpg</a><br />
These photos have been reduced in size to those used during the
preparation of the tutorial, but should allow you to test the procedures and get the same, or
very similar
results.<br />
<p>The image below is the result of stitching the two photos, using hugin
defaults. The photos contain moving people and the stitch shows that some of the people (lower-centre) are
partly displayed.<br />
<p>We will try an exclude mask then an include mask, to obtain a
better result.<br />
<p><img style="width: 800px; height: 749px;" alt="stitch no mask" src="stitch-nomask.jpg" /><br />
<h2><em><em>Using an Exclude mask</em></em></h2>
Start by launching Hugin, use the <span style="font-weight: bold;">Assistant
- 1. Load
images...</span> button to select the images, then use the <span style="font-weight: bold;">Assistant - 2.
Align...</span> button to optimise the alignment, then display a
preview of the stitch in the <span style="font-weight: bold;">Fast
Preview</span> window.<br />
<br />
<img style="width: 800px; height: 708px;" alt="all images" src="Screenshot-2.jpg" /><br />
<br />
Try switching individual images on and off in the <span style="font-weight: bold;">Fast Preview</span> window (toggle buttons
0, 1... in the <span style="font-weight: bold;">displayed images</span>
to see which parts of the overlapped regions could be excluded
to improve the final stitch. You will need to compare each image with
the result from the initial stitch to decide which parts of either
image should be masked to get a better result.<br />
Note that when we are looking to exclude part of an image, there needs
to be a suitable part in the same area of the overlapped image. The
blender must have something to replace the excluded area. If the
excluded area falls outside the overlap area the final stitch will
include a hole.<br />
<br />
<img style="width: 800px; height: 704px;" alt="one image" src="Screenshot-1.jpg" /><br />
<br />
We may have some success if we could exclude the young gentleman in the
lower centre foreground of photo #1.<br />
<br />
Select the <span style="font-weight: bold;">Mask</span> tab in the
main Hugin window, then select the image which contains the area to be
excluded. Go to the <span style="font-weight: bold;">Zoom:</span>
button to make the image a suitable a size to make it easy to select
mask boundary points.<br />
Select <span style="font-weight: bold;">Add new mask</span>, then
simply begin to define the mask boundary by selecting points with the
left mouse. Double click left mouse to end and close the polygon to the
first point.<br />
<br />
To edit your mask see <span style="font-weight: bold;">Mask editor key
later in this tutorial.<br />
<br />
You can download the masks, <a href="mask-1.msk">mask1</a>, <a href="mask-2.msk">mask2</a>. You may have to select the <span style="font-weight: bold;">scale</span> and/or <span style="font-weight: bold;">rotate</span> options when using <span style="font-weight: bold;">Load mask</span>,
to get the masks to align with the scaled images. Having loaded a mask,
you will need to select the appropriate image and then select the mask
to see the mask applied to the image.<br />
<br />
<img style="width: 800px; height: 600px;" alt="exclude mask" src="Screenshot-3.jpg" /><br />
<br />
This is the result of blend and stitch using the exclude mask.<br />
<br />
<img style="width: 800px; height: 749px;" alt="mask 1" src="stitch-mask1.jpg" /><br />
<br />
We will <span style="font-weight: bold;">Save mask</span> as it comes
in handy again later, then <span style="font-weight: bold;">Delete mask</span>
so that we can see how an Include mask works.<br />
<h2><em><em>Using an Include mask</em></em></h2>
Here we created an include mask on photo #0, and this is roughly
as shown in the image below.<br />
<br />
<img style="width: 800px; height: 732px;" alt="mask 2" src="Screenshot-4.jpg" /><br />
<br />
and the result of stitching and blending...<br />
<br />
<img style="width: 800px; height: 749px;" alt="include mask stitch" src="stitch-inc-mask.jpg" /><br />
<br />
which is almost identical to the result achieved using the more
detailed exclude mask.<br />
Again we <span style="font-weight: bold;">Save mask</span> before
trying the next section.<br />
<br />
<h2><em>A closer look at how the blender works</em></h2>
To get a better idea of how the blender works, we will colorize our two
images using Gimp, setting one to cyan and the other to red. If we set
the blender to use a narrow seam and no seam optimisation, we can see
how the blender handles the problem with no mask; an exclude mask, and
an include mask.<br />
<br />
Having loaded our two colorized photos, we can go to the <span style="font-weight: bold;">Stitcher</span> tab and set the enblend <span style="font-weight: bold;">Options</span> to <span style="font-weight: bold;">--no-optimize -l 4</span> to see how the
blender stitches without a mask. <br />
<br />
<img style="width: 800px; height: 856px;" alt="enblend options" src="Screenshot-5.jpg" /><br />
<br />
Go to the <span style="font-weight: bold;">Mask</span> tab and ensure
that no masks are defined. If masks are still defined, select each in
turn and <span style="font-weight: bold;">Delete mask</span>.<br />
The resulting blend and stitch shows us the seam line.<br />
<br />
<img style="width: 800px; height: 693px;" alt="colorize no-mask" src="stitch-colorize-nomask.jpg" /><br />
<br />
Note that the blend seam will be different to that of our original
stitch without a mask, because in that case we used the Enblend
defaults.<br />
<br />
If we now select the <span style="font-weight: bold;">Mask</span> tab
and <span style="font-weight: bold;">Load Mask</span> to retrieve our
exclude mask, then stitch from the <span style="font-weight: bold;">Stitcher</span>
tab so that we use our Enblend options, we see that the blend seam has
changed.<br />
<br />
<img style="width: 798px; height: 678px;" alt="colorize exclude mask" src="stitch-colorize-exclmask.jpg" /><br />
<br />
Note how the seam of the blend hasn't exactly followed the mask
boundary. The location of the seam line has been guided by the mask
boundary.<br />
<br />
If we now go back to the <span style="font-weight: bold;">Mask</span>
tab, select <span style="font-weight: bold;">Delete mask</span>, then
select <span style="font-weight: bold;">Load Mask</span> to load in
our include mask, and again stitch from the <span style="font-weight: bold;">Stitcher</span> tab, the result is...<br />
<br />
<img style="width: 798px; height: 678px;" alt="colorize include mask" src="stitch-colorize-incmask.jpg" /><br />
<br />
Again the seam has been guided by the mask boundary.<br />
<br />
The important thing to remember is that the masks must be defined
within the photo overlap region, otherwise a hole will appear in the
stitched image.<br />
Masking is quite easy to use once you are familiar with the basics, so
try things and experiment.<br />
<h2><em><em>&nbsp;</em>Mask editor key bindings</em></h2>
<span style="font-weight: bold;">Creating mask
Left mouse button sets one point, finish with right mouse button or
left click twice.<br />
<span style="font-weight: bold;">Select mask:</span> Left mouse click
inside polygon or use rubberband, works
only when there are no points selected; or use the listbox (i.e. select
<span style="font-weight: bold;">0 Exclude region</span> as in example
image above where we created our exclude mask).<br />
<span style="font-weight: bold;">Selecting point(s):</span> After
selecting <span style="font-weight: bold;">Add new mask</span> left
mouse click on point or use rubberband; when holding shift the new
points are added to an existing selection.<br />
<span style="font-weight: bold;">Move point(s):</span> drag with left
mouse button.<br />
<span style="font-weight: bold;">Move whole mask:</span> drag with
right mouse button.<br />
<span style="font-weight: bold;">Adding points:</span> Left click while
holding ctrl key on a line segment.<br />
<span style="font-weight: bold;">Deleting points:</span> Right mouse
click while holding ctrl key on a point or drag with right mouse button
and pressed ctrl key a rubber band around points (the remaining polygon
must consist of at least three points, otherwise the deleting is
cancelled); the delete key deletes the selected points.<br />
<span style="font-weight: bold;">Deleting mask:</span> Use <span style="font-weight: bold;">Delete mask</span> button. The mask is also
deleted by pressing the delete key when all&nbsp; or no points of the
current mask are selected.<br />
<br />
<h2><em>Other useful information</em></h2>
<em>To learn more about Enblend, the Hugin blender, go to the Hugin <span style="font-weight: bold;">Help</span>.
You should be able to navigate to the Enblend reference manual which
will explain all the options that can be used to fine tune the image
blending.<br />
<h2><em><em>Related links</em></em></h2>
<p><em>Bruno Postle has posted a <a href="http://www.flickr.com/photos/36383814@N00/4359863335/">tutorial</a>.<br />
<p><em>Cristian Marchi has posted a nice <a href="http://www.flickr.com/groups/hugin/discuss/72157623472700076/">tutorial</a>
showing the use of include (or 'positive') masking. <br />
<p><em><br />
<p><em>This tutorial prepared by Terry Duell with guidance from Bruno
Postle, Aug. 2010.<br />


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks