Masking for enblend with SVG and Inkscape
Here is an incredibly simple two shot panorama:
..notice that there are people right in the middle where the shots overlap. The Hugin 'Preview window' shows this quite well in 'difference' mode:
..where you can see the people and their shadow cover nearly the entire overlap area. I'll stitch this in Hugin using enblend (and I'll save the remapped images because we'll need them later):
..after rendering for some time, you can see that enblend has done a reasonable job by deciding to place the seam to include the people in the middle:
..though the seam cuts through their shadow in a strange way.
Now lets try to change the blend using Inkscape. The intermediate TIFF layers were saved earlier, they can be used to assemble an SVG file using tif2svg:
(this takes a while as it is tracing the alpha channel outlines and converting them to SVG clipping masks)
..once that is done, this SVG file can be opened in Inkscape. The images themselves are not changed, but are referenced in separate layers with some transparency to make them a bit easier to see:
Layers can be turned on and off. This tutorial is going to work on masking out the people in layer 0, I'll draw a polygon around the area that needs to be masked out:
..note that the polygon is a series of spline curves and can be re-edited easily. To combine this with the existing clipping mask, first select the image and 'release' the mask:
..releasing the mask turns it into a 'normal' polygon. Select both polygons:
..and create a combination of the two with the 'difference' function:
..this creates a single outline which can be use to set the new clip mask for the image:
The layer is now completely transparent where the people were masked out (though this can be edited at any point later):
Turn all the layers on, notice that the overlap is quite visible still:
..save the SVG file and close Inkscape if you like.
enblend-svg can now be used to split the layers in the SVG file to separate TIFF files and blend them with enblend:
..this takes some time as it is creating large temporary files..
..as well as running enblend. Though eventually it finishes:
The result is a TIFF file with the masked-out area ignored by the blend:
As a final note, there are two reasons for working like this: one is that drawing outlines is simpler in a dedicated vector art tool like Inkscape; the other is that the TIFF images themselves are not modified and can be deleted, the SVG file itself is just a few kB:
That's not quite it, 'positive' masking is a very similar process. If you want to positively include part of a layer instead of removing it, trace the outline as before, then move it to the another layer:
..combine this with the clipping mask here. Effectively forcing enblend to use the detail from the other layer for this area of the image:
Turn all the layers on and save the SVG file:
After blending the SVG file with enblend-svg, here is the result:
..the result is a TIFF file with the masked area 'masked-in', ie. positively masked.
tif2svg and enblend-mask can be found in the Panotools::Script perl module.
Bruno Postle - December 2007