%% This file is part of Enblend.
%% Licence details can be found in the file COPYING.


\chapter[Seam Generators]{\label{sec:seam-generators}%
  \genidx[\rangebeginlocation]{seam generation}%
  Seam Generators}

This version of \App{} supports two main algorithms to generate seam lines.  Use
option~\option{--primary-seam-generator}=\metavar{ALGORITHM} to select one of the generators.

\begin{description}
  \genidx[\summarylocation]{seam generation}%
  \genidx{nearest feature transform}%
  \gensee{NFT@\acronym{NFT}}{nearest feature transform}%
  \genidx{Alsuwaiyel, Muhammad@\propername{Alsuwaiyel, Muhammad H.}}%
  \genidx{Gavrilova, Marina@\propername{Gavrilova, Marina}}%
  \genidx{distance transform}%
  \gensee{DT@\acronym{DT}}{distance transform}%
\item[Nearest Feature Transform (\acronym{NFT})]%
\itemx[\metavar{ALGORITHM}=\code{nearest-feature-transform}]\itemend
  The Nearest Feature Transform\footnotemark{}, also known as
  \uref{\wikipediadistancetransform}{Distance Transform} (\acronym{DT}), is a fast and efficient
  technique to produce a seam line route given the geometries of multiple overlapping images.%
  %
  \footnotetext{\propername{Muhammad H. Alsuwaiyel} and \propername{Marina Gavrilova}, ``On the
    Distance Transform of Binary Images'', Proceedings of the International Conference on
    Imaging Science, Systems, and Technology, June 2000, \abbreviation{Vols.}~I and II,
    pages~83--86.}

  \acronym{NFT} as implemented in this version of \App{} only takes into account the \emph{shape
    of the overlap area.}  It completely ignore the images' contents.

  \genidx{graph-cut algorithm}%
  \gensee{GC@\acronym{GC}}{graph-cut algorithm}%
\item[Graph-Cut (\acronym{GC})]%
\itemx[\metavar{ALGORITHM}=\code{graph-cut}]\itemend
  \uref{\wikipediagraphcuts}{Graph-Cut} is a region-oriented way of segmenting images.

  The generator is based on the idea of finding a minimum cost ``cut'' of a graph created from a
  given image pair.  A ``cut'' is where the seam line appears.  \acronym{GC} determines the cost
  from the overlapping images' contents.
\end{description}

\genidx{seam generation!details}%
The most significant difference between the two algorithms is the output mask gradation.
\acronym{NFT} produces a coarse approximation of the seam, running as far away from the
overlap-region borders as possible.  The resulting mask could then be blended as-is, however,
\App{} by default runs image-content dependent optimizers to increase the mask gradation and for
example omits the regions where the images differ.  The result is a finer seam line, which only
loosely follows the shape of \acronym{NFT}'s primary seam.

\genidx{graphcut!details}%
Graph-Cut, on the other hand, is capable of producing the final mask in one pass without the
need of further optimizers.  It looks for a seam line that is \emph{globally} optimal, taking
into account feature frequency, as well as image dissimilarity.  This means, the seam is less
likely to cross lines like for example fences, lampposts, or road markings, where they would be
visible.

The optimizers which run after \acronym{NFT} can also be run after \acronym{GC}.  Nevertheless,
\acronym{GC} works best just with a fine mask (option~\option{--fine-mask}); optimizers are then
automatically \emph{turned off} to take full advantage of the detailed seam \acronym{GC}
produces.

\acronym{GC} requires more memory and computation time to complete than \acronym{NFT}.  Thus, it
is best to prefer \acronym{NFT} where the images used are large and execution time is crucial.
If quality is the priority, using \acronym{GC} and fine mask usually produces visually more
pleasing results.

\genidx{graphcut!limitations}%
\acronym{GC} is currently limited to seams that begin and end on the images' borders.  This
means that the algorithm cannot run in cases where, for example, one image is contained in
another, resulting in a loop-like seam.  In such cases, though, \App{} automatically falls back
to a \acronym{NFT}-generated seam, making its application transparent to the user.

\genidx[\rangeendlocation]{seam generation}


%%% Local Variables:
%%% fill-column: 96
%%% End:
