From: Enblend <enb...@li...> - 2011-09-04 08:14:57
|
branch: details: http://enblend.hg.sourceforge.net/hgweb/enblend/enblend/hgrepo/e/en/enblend/enblend/rev/94f527d936da changeset: 752:94f527d936da user: Chris <cs...@us...> date: Sun Sep 04 09:46:05 2011 +0200 description: Add new difference algorithm and make it user-selectable with option `--image-difference'. The new algorithm uses "delta E" as pixel difference. Both algorithms can now be tuned with user-defined weights for the luminance and the chrominance part in the difference image. diffstat: NEWS | 9 + VERSION | 2 +- doc/enblend.info | 0 doc/enblend.texi | 599 +++++++++++++++++++++++++++++++++++++++++++++++++++ doc/enfuse.info | 0 doc/versenblend.texi | 8 +- doc/versenfuse.texi | 8 +- src/common.h | 9 + src/enblend.1 | 17 +- src/enblend.cc | 143 +++++++++++- src/enfuse.1 | 4 +- src/enfuse.h | 6 - src/graphcut.h | 23 +- src/mask.h | 23 +- src/maskcommon.h | 147 +++++++++-- 15 files changed, 930 insertions(+), 68 deletions(-) diffs (truncated from 1253 to 500 lines): diff -r 92b47705efa6 -r 94f527d936da NEWS --- a/NEWS Sun Sep 04 09:45:07 2011 +0200 +++ b/NEWS Sun Sep 04 09:46:05 2011 +0200 @@ -10,6 +10,11 @@ has been implemented during GSoC 2011 by Mikołaj Leszczyński. It is the default now. +- The difference image on which Enblend's seam-line optimization + relies for color images uses a perceptual model by default (option + "--image-difference"), yielding a true CIE76 "Delta E" with the + (default) luminance and chrominance weights of 1. + - Parallelize CIECAM02 color conversion (option "--ciecam"). Speedups of up to 40% have been reported on the amd64 architecture. The computationally expensive color-space conversion still slows down @@ -56,6 +61,10 @@ - Option "--primary-seam-generator" controls the primary seam-line generation algorithm. +- Option "--image-difference" selects the difference image calculation + algorithm and optionally assigns weights to the luminance and the + chrominance part of the difference image. + - Short option "-c" now has a sibling called "--ciecam". The long option also has a negated form: "--no-ciecam"; the short one has not. diff -r 92b47705efa6 -r 94f527d936da VERSION --- a/VERSION Sun Sep 04 09:45:07 2011 +0200 +++ b/VERSION Sun Sep 04 09:46:05 2011 +0200 @@ -1,1 +1,1 @@ -4.1-17310158164d +4.1-92b47705efa6 diff -r 92b47705efa6 -r 94f527d936da doc/enblend.info Binary file doc/enblend.info has changed diff -r 92b47705efa6 -r 94f527d936da doc/enblend.texi --- a/doc/enblend.texi Sun Sep 04 09:45:07 2011 +0200 +++ b/doc/enblend.texi Sun Sep 04 09:46:05 2011 +0200 @@ -1596,6 +1596,605 @@ Also see @ref{Table:mask-generation}. +@item --image-difference=@var{ALGORITHM}[:@var{LUMINANCE-WEIGHT}[:@var{CHROMINANCE-WEIGHT}]] +@opindex --image-difference +@cindex image difference +@cindex difference image +@cindex luminance weight +@cindex weight, luminance +@cindex chrominance weight +@cindex weight, chrominance + +Enblend calculates the difference of a pair of overlapping color +images when it generates the primary seam with a Graph-Cut or before +it optimizes a seam. It employs a user-selectable @var{ALGORITHM} +that itself is controlled by the weights for luminance differences +@var{LUMINANCE-WEIGHT}, +@ifinfo +@math{w_luminance} +@end ifinfo +@html +<mathinline xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> + <mrowinline> + <msubinline> + <mi>w</mi> + <mtext>luminance</mtext> + </msubinline> + </mrowinline> +</mathinline> +@end html +@tex +$w_{\mathrm{luminance}}$ +@end tex +@docbook +<inlineequation> + <mml:math> + <mml:csymbol> + <mml:msub> + <mml:mi mathvariant="italic">w</mml:mi> + <mml:mi mathvariant="normal">luminance</mml:mi> + </mml:msub> + </mml:csymbol> + </mml:math> +</inlineequation> +@end docbook +and color differences @var{CHROMINANCE-WEIGHT}, +@ifinfo +@math{w_chrominance}. +@end ifinfo +@html +<mathinline xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> + <mrowinline> + <msubinline> + <mi>w</mi> + <mtext>chrominance</mtext> + </msubinline> + <mtext>.</mtext> + </mrowinline> +</mathinline> +@end html +@tex +$w_{\mathrm{chrominance}}$. +@end tex +@docbook +<inlineequation> + <mml:math> + <mml:csymbol> + <mml:msub> + <mml:mi mathvariant="italic">w</mml:mi> + <mml:mi mathvariant="normal">chrominance</mml:mi> + </mml:msub> + </mml:csymbol> + </mml:math> +</inlineequation> +@end docbook + +For black-and-white images the difference is simple the absolute +difference of each pair of pixels. + +@table @code +@item maximum-hue-luminance +@itemx maximum-hue-lum +@itemx max-hue-luminance +@itemx max-hue-lum +@itemx max +@cindex maximum hue-luminance +@cindex hue-luminance maximum +@cindex luminance-hue maximum +Calculate the difference@tie{}@math{d} as the maximum of the +differences of the luminances@tie{}@math{l} and hues@tie{}@math{h} of +each pair of pixels +@ifinfo +@math{P1} +@end ifinfo +@html +<mathinline xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> + <mrowinline> + <msubinline> + <mi>P</mi> + <mn>1</mn> + </msubinline> + </mrowinline> +</mathinline> +@end html +@tex +$P_1$ +@end tex +@docbook +<inlineequation> + <mml:math> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>1</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:math> +</inlineequation> +@end docbook +and +@ifinfo +@math{P2}: +@end ifinfo +@html +<mathinline xmlns="http://www.w3.org/1998/Math/MathML" display="inline"> + <mrowinline> + <msubinline> + <mi>P</mi> + <mn>2</mn> + </msubinline> + <mtext>:</mtext> + </mrowinline> +</mathinline> +@end html +@tex +$P_2$: +@end tex +@docbook +<inlineequation> + <mml:math> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>2</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:math> +</inlineequation> +@end docbook + +@ifinfo +@display +@math{d = max(w_luminance * |l(P_1) - l(P_2)|, w_chrominance * |h(P_1) - h(p_2)|)} +@end display +@end ifinfo +@html +<math xmlns="http://www.w3.org/1998/Math/MathML" display="separate"> + <mrow> + <mi>d</mi> + <mo>=</mo> + <mrow> + <mo>max</mo> + <mo>⁡</mo> + <mfenced> + <mrow> + <msub> + <mi>w</mi> + <mtext>luminance</mtext> + </msub> + <mo>×</mo> + <mrow> + <mo>|</mo> + <mi>l</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>1</mn> + </msub> + </mfenced> + <mo>-</mo> + <mi>l</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>2</mn> + </msub> + </mfenced> + <mo>|</mo> + </mrow> + </mrow> + + <mrow> + <msub> + <mi>w</mi> + <mtext>chrominance</mtext> + </msub> + <mo>×</mo> + <mrow> + <mo>|</mo> + <mi>h</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>1</mn> + </msub> + </mfenced> + <mo>-</mo> + <mi>h</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>2</mn> + </msub> + </mfenced> + <mo>|</mo> + </mrow> + </mrow> + </mfenced> + </mrow> + </mrow> +</math> +@end html +@tex +$$ + \eqalign{d = \max(& w_{\mathrm{luminance}} \times |l(P_1) - l(P_2)|, \cr + & w_{\mathrm{chrominance}} \times |h(P_1) - h(P_2)|) \cr} +$$ +@end tex +@docbook +<informalequation> + <mml:math> + <mml:apply> + <mml:eq/> + <mml:ci>d</mml:ci> + <mml:apply> + <mml:max/> + <mml:apply> + <mml:times/> + <mml:csymbol> + <mml:msub> + <mml:mi>w</mml:mi> + <mml:mi mathvariant="normal">luminance</mml:mi> + </mml:msub> + </mml:csymbol> + <mml:apply> + <mml:abs/> + <mml:apply> + <mml:minus/> + <mml:apply> + <mml:ci>l</mml:ci> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>1</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:apply> + <mml:apply> + <mml:ci>l</mml:ci> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>2</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:apply> + </mml:apply> + </mml:apply> + </mml:apply> + <mml:apply> + <mml:times/> + <mml:csymbol> + <mml:msub> + <mml:mi>w</mml:mi> + <mml:mi mathvariant="normal">chrominance</mml:mi> + </mml:msub> + </mml:csymbol> + <mml:apply> + <mml:abs/> + <mml:apply> + <mml:minus/> + <mml:apply> + <mml:ci>h</mml:ci> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>1</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:apply> + <mml:apply> + <mml:ci>h</mml:ci> + <mml:csymbol> + <mml:msub> + <mml:mi>P</mml:mi> + <mml:cn>2</mml:cn> + </mml:msub> + </mml:csymbol> + </mml:apply> + </mml:apply> + </mml:apply> + </mml:apply> + </mml:apply> + </mml:apply> + </mml:math> +</informalequation> +@end docbook + +This algorithm was the default for Enblend up to version@tie{}4.0. + +@item delta-e +@itemx de +@cindex delta-E +Calulate the difference@tie{}@math{d} as the @sc{Euclidean} distance +of the pixels in L*a*b* space: +@ifinfo +@display +@math{d = sqrt(w_luminance * (L(P_1) - L(P_2))^2 + + w_chrominance * (a(P_1) - a(P_2))^2 + + w_chrominance * (b(P_1) - b(P_2))^2)} +@end display +@end ifinfo +@html +<math xmlns="http://www.w3.org/1998/Math/MathML" display="separate"> + <mrow> + <mi>d</mi> + <mo>=</mo> + <msup> + <mrow> + <mo>(</mo> + <mrow> + <msub> + <mi>w</mi> + <mtext>luminance</mtext> + </msub> + <mo>×</mo> + <msup> + <mrow> + <mo>(</mo> + <mi>L</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>1</mn> + </msub> + </mfenced> + <mo>-</mo> + <mi>L</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>2</mn> + </msub> + </mfenced> + <mo>)</mo> + </mrow> + <mn>2</mn> + </msup> + </mrow> + <mo>+</mo> + <mrow> + <msub> + <mi>w</mi> + <mtext>chrominance</mtext> + </msub> + <mo>×</mo> + <msup> + <mrow> + <mo>(</mo> + <mi>a</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>1</mn> + </msub> + </mfenced> + <mo>-</mo> + <mi>a</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>2</mn> + </msub> + </mfenced> + <mo>)</mo> + </mrow> + <mn>2</mn> + </msup> + </mrow> + <mo>+</mo> + <mrow> + <msub> + <mi>w</mi> + <mtext>chrominance</mtext> + </msub> + <mo>×</mo> + <msup> + <mrow> + <mo>(</mo> + <mi>b</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>1</mn> + </msub> + </mfenced> + <mo>-</mo> + <mi>b</mi> + <mo>⁡</mo> + <mfenced> + <msub> + <mi>P</mi> + <mn>2</mn> + </msub> + </mfenced> + <mo>)</mo> + </mrow> + <mn>2</mn> + </msup> + </mrow> + <mo>)</mo> + </mrow> + <mn>1/2</mn> + </msup> + </mrow> +</math> +@end html +@tex +$$ + \eqalign{d = (& w_{\mathrm{luminance}} \, \times (L(P_1) - L(P_2))^2 \; + \cr + & w_{\mathrm{chrominance}} \, \times (a(P_1) - a(P_2))^2 \; + \cr + & w_{\mathrm{chrominance}} \, \times (b(P_1) - b(P_2))^2)^{1/2}\cr} +$$ +@end tex +@docbook +<informalequation> + <mml:math> + <mml:apply> + <mml:eq/> + <mml:ci>d</mml:ci> + <mml:apply> + <mml:power/> + <!-- base --> + <mml:apply> + <mml:csymbol><!-- empty --></mml:csymbol> + <mml:apply> + <mml:plus/> + <!-- first summand --> + <mml:apply> + <mml:times/> + <mml:csymbol> + <mml:msub> + <mml:mi>w</mml:mi> |