[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

details vigra/combineimages.hxx VIGRA

00001 /************************************************************************/
00002 /*                                                                      */
00003 /*               Copyright 1998-2002 by Ullrich Koethe                  */
00004 /*       Cognitive Systems Group, University of Hamburg, Germany        */
00005 /*                                                                      */
00006 /*    This file is part of the VIGRA computer vision library.           */
00007 /*    ( Version 1.2.0, Aug 07 2003 )                                    */
00008 /*    You may use, modify, and distribute this software according       */
00009 /*    to the terms stated in the LICENSE file included in               */
00010 /*    the VIGRA distribution.                                           */
00011 /*                                                                      */
00012 /*    The VIGRA Website is                                              */
00013 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
00014 /*    Please direct questions, bug reports, and contributions to        */
00015 /*        koethe@informatik.uni-hamburg.de                              */
00016 /*                                                                      */
00017 /*  THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR          */
00018 /*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED      */
00019 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
00020 /*                                                                      */
00021 /************************************************************************/
00022  
00023  
00024 #ifndef VIGRA_COMBINEIMAGES_HXX
00025 #define VIGRA_COMBINEIMAGES_HXX
00026 
00027 #include "vigra/utilities.hxx"
00028 #include "vigra/numerictraits.hxx"
00029 #include <cmath>
00030 
00031 namespace vigra {
00032 
00033 /** \addtogroup CombineAlgo Algorithms to Combine Images
00034 
00035     Apply functor to calculate a pixelwise transformation depending on multiple images.
00036     Note that the binary functors of the STL may be used with these functions.
00037 */
00038 //@{
00039 
00040 /********************************************************/
00041 /*                                                      */
00042 /*                    combine...Lines                   */
00043 /*                                                      */
00044 /********************************************************/
00045 
00046 template <class SrcIterator1, class SrcAccessor1,
00047           class SrcIterator2, class SrcAccessor2,
00048           class DestIterator, class DestAccessor, class Functor>
00049 void
00050 combineTwoLines(SrcIterator1 s1, 
00051                 SrcIterator1 s1end, SrcAccessor1 src1,
00052                 SrcIterator2 s2, SrcAccessor2 src2,
00053                 DestIterator d, DestAccessor dest,
00054                 Functor const & f)
00055 {
00056     for(; s1 != s1end; ++s1, ++s2, ++d)
00057         dest.set(f(src1(s1), src2(s2)), d);
00058 }
00059 
00060 template <class SrcIterator1, class SrcAccessor1,
00061           class SrcIterator2, class SrcAccessor2,
00062           class MaskIterator, class MaskAccessor, 
00063           class DestIterator, class DestAccessor, class Functor>
00064 void
00065 combineTwoLinesIf(SrcIterator1 s1, 
00066                   SrcIterator1 s1end, SrcAccessor1 src1,
00067                   SrcIterator2 s2, SrcAccessor2 src2,
00068                   MaskIterator m, MaskAccessor mask,
00069                   DestIterator d, DestAccessor dest,
00070                   Functor const & f)
00071 {
00072     for(; s1 != s1end; ++s1, ++s2, ++m, ++d)
00073         if(mask(m))
00074             dest.set(f(src1(s1), src2(s2)), d);
00075 }
00076 
00077 template <class SrcIterator1, class SrcAccessor1,
00078           class SrcIterator2, class SrcAccessor2,
00079           class SrcIterator3, class SrcAccessor3,
00080           class DestIterator, class DestAccessor, class Functor>
00081 void
00082 combineThreeLines(SrcIterator1 s1, 
00083                   SrcIterator1 s1end, SrcAccessor1 src1,
00084                   SrcIterator2 s2, SrcAccessor2 src2,
00085                   SrcIterator3 s3, SrcAccessor3 src3,
00086                   DestIterator d, DestAccessor dest,
00087                   Functor const & f)
00088 {
00089     for(; s1 != s1end; ++s1, ++s2, ++s3, ++d)
00090         dest.set(f(src1(s1), src2(s2), src3(s3)), d);
00091 }
00092 
00093 /********************************************************/
00094 /*                                                      */
00095 /*                    combineTwoImages                  */
00096 /*                                                      */
00097 /********************************************************/
00098 
00099 /** \brief Combine two source images into destination image.
00100 
00101     The transformation given by the functor is applied to the source 
00102     pixels and the result written into the corresponding destination pixel.
00103     This is typically used for operations like add and subtract.
00104     The function uses accessors to access the pixel data.
00105     Note that the binary functors of the STL can be used in addition to
00106     the functors specifically defined in \ref CombineFunctor.
00107     Creation of new functors is easiest by using \ref FunctorExpressions.
00108     
00109     <b> Declarations:</b>
00110     
00111     pass arguments explicitly:
00112     \code
00113     namespace vigra {
00114         template <class SrcImageIterator1, class SrcAccessor1,
00115               class SrcImageIterator2, class SrcAccessor2,
00116               class DestImageIterator, class DestAccessor,
00117               class Functor>
00118         void
00119         combineTwoImages(SrcImageIterator1 src1_upperleft, 
00120                  SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00121                  SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00122                  DestImageIterator dest_upperleft, DestAccessor da,
00123                  Functor const & f)
00124     }
00125     \endcode
00126     
00127     
00128     use argument objects in conjuction with \ref ArgumentObjectFactories:
00129     \code
00130     namespace vigra {
00131         template <class SrcImageIterator1, class SrcAccessor1,
00132               class SrcImageIterator2, class SrcAccessor2,
00133               class DestImageIterator, class DestAccessor,
00134               class Functor>
00135         void
00136         combineTwoImages(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00137                  pair<SrcImageIterator2, SrcAccessor2> src2,
00138                  pair<DestImageIterator, DestAccessor> dest,
00139                  Functor const & f)
00140     }
00141     \endcode
00142     
00143     <b> Usage:</b>
00144     
00145         <b>\#include</b> "<a href="combineimages_8hxx-source.html">vigra/combineimages.hxx</a>"<br>
00146         Namespace: vigra
00147     
00148     \code
00149     #include <functional>     // for plus
00150 
00151     vigra::combineTwoImages(
00152                 srcIterRange(src1.upperLeft(), src1.lowerRight()), 
00153                 srcIter(src2.upperLeft()), 
00154                 destIter(dest.upperLeft()),  
00155                 std::plus<SrcValueType>());
00156     
00157     \endcode
00158     
00159     Note that <TT>SrcValueType</TT> must be replaced with the appropriate type (e.g. 
00160     the promote type of the input images' pixel type, see also 
00161     \ref NumericPromotionTraits)
00162     
00163     <b> Required Interface:</b>
00164     
00165     \code
00166     SrcImageIterator1 src1_upperleft, src1_lowerright;
00167     SrcImageIterator2 src2_upperleft;
00168     DestImageIterator dest_upperleft;
00169     SrcImageIterator1::row_iterator sx1 = src1_upperleft.rowIterator();
00170     SrcImageIterator2::row_iterator sx2 = src2_upperleft.rowIterator();
00171     DestImageIterator::row_iterator dx = dest_upperleft.rowIterator();
00172     
00173     SrcAccessor1 src1_accessor;
00174     SrcAccessor2 src2_accessor;
00175     DestAccessor dest_accessor;
00176     
00177     Functor functor;
00178 
00179     dest_accessor.set(
00180           functor(src1_accessor(sx1), src2_accessor(sx2)), 
00181           dx);
00182 
00183     \endcode
00184     
00185     
00186 */
00187 template <class SrcImageIterator1, class SrcAccessor1,
00188           class SrcImageIterator2, class SrcAccessor2,
00189       class DestImageIterator, class DestAccessor,
00190           class Functor>
00191 void
00192 combineTwoImages(SrcImageIterator1 src1_upperleft, 
00193                  SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00194                  SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00195                  DestImageIterator dest_upperleft, DestAccessor da,
00196          Functor const & f)
00197 {
00198     int w = src1_lowerright.x - src1_upperleft.x;
00199     
00200     for(; src1_upperleft.y < src1_lowerright.y; 
00201             ++src1_upperleft.y, ++src2_upperleft.y, ++dest_upperleft.y)
00202     {
00203         combineTwoLines(src1_upperleft.rowIterator(), 
00204                         src1_upperleft.rowIterator() + w, sa1, 
00205                         src2_upperleft.rowIterator(), sa2, 
00206                         dest_upperleft.rowIterator(), da, f);
00207     }
00208 }
00209     
00210 template <class SrcImageIterator1, class SrcAccessor1,
00211           class SrcImageIterator2, class SrcAccessor2,
00212       class DestImageIterator, class DestAccessor,
00213           class Functor>
00214 inline
00215 void
00216 combineTwoImages(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00217              pair<SrcImageIterator2, SrcAccessor2> src2,
00218              pair<DestImageIterator, DestAccessor> dest,
00219          Functor const & f)
00220 {
00221     combineTwoImages(src1.first, src1.second, src1.third, 
00222                      src2.first, src2.second, 
00223              dest.first, dest.second, f);
00224 }
00225 
00226 /********************************************************/
00227 /*                                                      */
00228 /*                  combineTwoImagesIf                  */
00229 /*                                                      */
00230 /********************************************************/
00231 
00232 /** \brief Combine ROI of two source images into destination image.
00233 
00234     The transformation given by the functor is applied to all source 
00235     pixels in the ROI (i.e. whenever the return value of the mask's accessor
00236     is not zero)
00237     and the result written into the corresponding destination pixel.
00238     This is typically used for operations like add and subtract.
00239     The function uses accessors to access the pixel data.
00240     Note that the binary functors of the STL can be used in addition to
00241     the functors specifically defined in \ref CombineFunctor.
00242     Creation of new functors is easiest by using \ref FunctorExpressions.
00243     
00244     <b> Declarations:</b>
00245     
00246     pass arguments explicitly:
00247     \code
00248     namespace vigra {
00249         template <class SrcImageIterator1, class SrcAccessor1,
00250               class SrcImageIterator2, class SrcAccessor2,
00251               class MaskImageIterator, class MaskAccessor,
00252               class DestImageIterator, clas DestAccessor,
00253               class Functor>
00254         void
00255         combineTwoImagesIf(SrcImageIterator1 src1_upperleft, 
00256                    SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00257                    SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00258                    MaskImageIterator mask_upperleft, MaskAccessor ma,
00259                    DestImageIterator dest_upperleft, DestAccessor da,
00260                    Functor const & f)
00261     }
00262     \endcode
00263     
00264     
00265     use argument objects in conjuction with \ref ArgumentObjectFactories:
00266     \code
00267     namespace vigra {
00268         template <class SrcImageIterator1, class SrcAccessor1,
00269               class SrcImageIterator2, class SrcAccessor2,
00270               class MaskImageIterator, class MaskAccessor,
00271               class DestImageIterator, clas DestAccessor,
00272               class Functor>
00273         void
00274         combineTwoImagesIf(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00275                    pair<SrcImageIterator2, SrcAccessor2> src2,
00276                    pair<MaskImageIterator, MaskAccessor> mask,
00277                    pair<DestImageIterator, DestAccessor> dest,
00278                    Functor const & f)
00279     }
00280     \endcode
00281     
00282     <b> Usage:</b>
00283     
00284         <b>\#include</b> "<a href="combineimages_8hxx-source.html">vigra/combineimages.hxx</a>"<br>
00285         Namespace: vigra
00286     
00287     \code
00288     #include <functional>     // for plus
00289 
00290     vigra::combineTwoImagesIf(
00291                 srcIterRange(src1.upperLeft(), src1.lowerRight()), 
00292                 srcIter(src2.upperLeft()), 
00293                 maskIter(mask.upperLeft()), 
00294                 destIter(dest.upperLeft()),
00295                 std::plus<SrcValueType>());
00296     
00297     \endcode
00298 
00299     Note that <TT>SrcValueType</TT> must be replaced with the appropriate type (e.g. 
00300     the promote type of the input images' pixel type, see also 
00301     \ref NumericPromotionTraits)
00302     
00303     <b> Required Interface:</b>
00304     
00305     \code
00306     SrcImageIterator1 src1_upperleft, src1_lowerright;
00307     SrcImageIterator2 src2_upperleft;
00308     MaskImageIterator mask_upperleft;
00309     DestImageIterator dest_upperleft;
00310     SrcImageIterator1::row_iterator sx1 = src1_upperleft.rowIterator();
00311     SrcImageIterator2::row_iterator sx2 = src2_upperleft.rowIterator();
00312     MaskImageIterator::row_iterator mx = mask_upperleft.rowIterator();
00313     DestImageIterator::row_iterator dx = dest_upperleft.rowIterator();
00314     
00315     
00316     SrcAccessor1 src1_accessor;
00317     SrcAccessor2 src2_accessor;
00318     MaskAccessor mask_accessor;
00319     DestAccessor dest_accessor;
00320     
00321     Functor functor;
00322     
00323     if(mask_accessor(mx))
00324        dest_accessor.set(
00325           functor(src1_accessor(sx1), src2_accessor(sx2)), 
00326           dx);
00327 
00328     \endcode
00329     
00330 */
00331 template <class SrcImageIterator1, class SrcAccessor1,
00332           class SrcImageIterator2, class SrcAccessor2,
00333           class MaskImageIterator, class MaskAccessor,
00334           class DestImageIterator, class DestAccessor,
00335       class Functor>
00336 void
00337 combineTwoImagesIf(SrcImageIterator1 src1_upperleft, 
00338                    SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00339                    SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00340                    MaskImageIterator mask_upperleft, MaskAccessor ma,
00341                DestImageIterator dest_upperleft, DestAccessor da,
00342                Functor const & f)
00343 {
00344     int w = src1_lowerright.x - src1_upperleft.x;
00345     
00346     for(; src1_upperleft.y < src1_lowerright.y;
00347           ++src1_upperleft.y, ++src2_upperleft.y, 
00348           ++dest_upperleft.y, ++mask_upperleft.y)
00349     {
00350         combineTwoLinesIf(src1_upperleft.rowIterator(), 
00351                           src1_upperleft.rowIterator() + w, sa1, 
00352                           src2_upperleft.rowIterator(), sa2, 
00353                           mask_upperleft.rowIterator(), ma, 
00354                           dest_upperleft.rowIterator(), da, f);
00355     }
00356 }
00357     
00358 template <class SrcImageIterator1, class SrcAccessor1,
00359           class SrcImageIterator2, class SrcAccessor2,
00360           class MaskImageIterator, class MaskAccessor,
00361           class DestImageIterator, class DestAccessor,
00362       class Functor>
00363 inline
00364 void
00365 combineTwoImagesIf(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00366                pair<SrcImageIterator2, SrcAccessor2> src2,
00367                pair<MaskImageIterator, MaskAccessor> mask,
00368                pair<DestImageIterator, DestAccessor> dest,
00369                Functor const & f)
00370 {
00371     combineTwoImagesIf(src1.first, src1.second, src1.third, 
00372                        src2.first, src2.second, 
00373                        mask.first, mask.second, 
00374                        dest.first, dest.second, f);
00375 }
00376 
00377 /********************************************************/
00378 /*                                                      */
00379 /*                  combineThreeImages                  */
00380 /*                                                      */
00381 /********************************************************/
00382 
00383 /** \brief Combine three source images into destination image.
00384 
00385     The transformation given by the functor is applied to the source 
00386     pixels and the result written into the corresponding destination pixel.
00387     The function uses accessors to access the pixel data.
00388     Creation of new functors is easiest by using \ref FunctorExpressions.
00389     
00390     <b> Declarations:</b>
00391     
00392     pass arguments explicitly:
00393     \code
00394     namespace vigra {
00395         template <class SrcImageIterator1, class SrcAccessor1,
00396               class SrcImageIterator2, class SrcAccessor2,
00397               class SrcImageIterator3, class SrcAccessor3,
00398               class DestImageIterator, class DestAccessor,
00399               class Functor>
00400         void
00401         combineThreeImages(SrcImageIterator1 src1_upperleft, 
00402                    SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00403                    SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00404                    SrcImageIterator3 src2_upperleft, SrcAccessor3 sa3,
00405                    DestImageIterator dest_upperleft, DestAccessor da,
00406                    Functor const & f)
00407     }
00408     \endcode
00409     
00410     
00411     use argument objects in conjuction with \ref ArgumentObjectFactories:
00412     \code
00413     namespace vigra {
00414         template <class SrcImageIterator1, class SrcAccessor1,
00415               class SrcImageIterator2, class SrcAccessor2,
00416               class SrcImageIterator3, class SrcAccessor3,
00417               class DestImageIterator, class DestAccessor,
00418               class Functor>
00419         void
00420         combineThreeImages(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00421                  pair<SrcImageIterator2, SrcAccessor2> src2,
00422                  pair<SrcImageIterator3, SrcAccessor3> src3,
00423                  pair<DestImageIterator, DestAccessor> dest,
00424                  Functor const & f)
00425     }
00426     \endcode
00427     
00428     <b> Usage:</b>
00429     
00430         <b>\#include</b> "<a href="combineimages_8hxx-source.html">vigra/combineimages.hxx</a>"<br>
00431         Namespace: vigra
00432     
00433     \code
00434     vigra::combineThreeImages(
00435                 srcIterRange(src1.upperLeft(), src1.lowerRight()), 
00436                 srcIter(src2.upperLeft()), 
00437                 srcIter(src3.upperLeft()), 
00438                 destIter(dest.upperLeft()),  
00439                 SomeThreeArgumentFunctor());
00440     
00441     \endcode
00442 
00443     <b> Required Interface:</b>
00444     
00445     \code
00446     SrcImageIterator1 src1_upperleft, src1_lowerright;
00447     SrcImageIterator2 src2_upperleft;
00448     SrcImageIterator3 src3_upperleft;
00449     DestImageIterator dest_upperleft;
00450     SrcImageIterator1::row_iterator sx1 = src1_upperleft.rowIterator();
00451     SrcImageIterator2::row_iterator sx2 = src2_upperleft.rowIterator();
00452     SrcImageIterator3::row_iterator sx3 = src3_upperleft.rowIterator();
00453     DestImageIterator::row_iterator dx = dest_upperleft.rowIterator();
00454     
00455     SrcAccessor1 src1_accessor;
00456     SrcAccessor2 src2_accessor;
00457     SrcAccessor3 src3_accessor;
00458     DestAccessor dest_accessor;
00459     
00460     Functor functor;
00461 
00462     dest_accessor.set(
00463           functor(src1_accessor(sx1), 
00464                   src2_accessor(sx2), 
00465                   src3_accessor(sx3)), 
00466           dx);
00467 
00468     \endcode
00469     
00470     
00471 */
00472 template <class SrcImageIterator1, class SrcAccessor1,
00473           class SrcImageIterator2, class SrcAccessor2,
00474           class SrcImageIterator3, class SrcAccessor3,
00475           class DestImageIterator, class DestAccessor,
00476           class Functor>
00477 void
00478 combineThreeImages(SrcImageIterator1 src1_upperleft, 
00479                    SrcImageIterator1 src1_lowerright, SrcAccessor1 sa1,
00480                    SrcImageIterator2 src2_upperleft, SrcAccessor2 sa2,
00481                    SrcImageIterator3 src3_upperleft, SrcAccessor3 sa3,
00482                    DestImageIterator dest_upperleft, DestAccessor da,
00483                    Functor const & f)
00484 {
00485     int w = src1_lowerright.x - src1_upperleft.x;
00486     
00487     for(; src1_upperleft.y < src1_lowerright.y;
00488         ++src1_upperleft.y, ++src2_upperleft.y, ++src3_upperleft.y, 
00489         ++dest_upperleft.y)
00490     {
00491         combineThreeLines(src1_upperleft.rowIterator(), 
00492                           src1_upperleft.rowIterator() + w, sa1, 
00493                           src2_upperleft.rowIterator(), sa2, 
00494                           src3_upperleft.rowIterator(), sa3, 
00495                           dest_upperleft.rowIterator(), da, f);
00496     }
00497 }
00498     
00499 template <class SrcImageIterator1, class SrcAccessor1,
00500           class SrcImageIterator2, class SrcAccessor2,
00501           class SrcImageIterator3, class SrcAccessor3,
00502           class DestImageIterator, class DestAccessor,
00503           class Functor>
00504 inline
00505 void
00506 combineThreeImages(triple<SrcImageIterator1, SrcImageIterator1, SrcAccessor1> src1,
00507              pair<SrcImageIterator2, SrcAccessor2> src2,
00508              pair<SrcImageIterator3, SrcAccessor3> src3,
00509              pair<DestImageIterator, DestAccessor> dest,
00510              Functor const & f)
00511 {
00512     combineThreeImages(src1.first, src1.second, src1.third, 
00513                      src2.first, src2.second, 
00514                      src3.first, src3.second, 
00515                      dest.first, dest.second, f);
00516 }
00517 
00518     
00519 //@}
00520 
00521 /** \addtogroup CombineFunctor Functors to Combine Images
00522 
00523     Common functors with several arguments
00524 */
00525 //@{
00526 
00527 /********************************************************/
00528 /*                                                      */
00529 /*                    MagnitudeFunctor                  */
00530 /*                                                      */
00531 /********************************************************/
00532 
00533 /** Calculate the magnitude from two arguments.
00534     Can be used in conjunction with \ref gradientBasedTransform().
00535 */
00536 template <class ValueType>
00537 class MagnitudeFunctor
00538 {
00539   public:
00540         /** the functor's first argument type
00541         */
00542     typedef ValueType first_argument_type;
00543     
00544         /** the functor's second argument type
00545         */
00546     typedef ValueType second_argument_type;
00547     
00548         /** the functor's result type
00549         */
00550     typedef typename NumericTraits<ValueType>::RealPromote result_type;
00551     
00552         /** \deprecated use first_argument_type, second_argument_type, result_type
00553         */
00554     typedef ValueType value_type;
00555     
00556         /** calculate transform '<TT>sqrt(v1*v1 + v2*v2)</TT>'. 
00557             
00558         */
00559     result_type operator()(first_argument_type const & v1, second_argument_type const & v2) const
00560     {
00561         return VIGRA_CSTD::sqrt(v1*v1 + v2*v2);
00562     }
00563 };
00564 
00565 /********************************************************/
00566 /*                                                      */
00567 /*             RGBGradientMagnitudeFunctor              */
00568 /*                                                      */
00569 /********************************************************/
00570 
00571 
00572 /** Calculate the gradient magnitude from RGB arguments.
00573     Can be used in conjunction with \ref gradientBasedTransform().
00574 */
00575 template <class ValueType>
00576 class RGBGradientMagnitudeFunctor
00577 {
00578   public:
00579         /** the functor's first argument type
00580         */
00581     typedef RGBValue<ValueType> first_argument_type;
00582     
00583         /** the functor's second argument type
00584         */
00585     typedef RGBValue<ValueType> second_argument_type;
00586     
00587         /** the functor's result type
00588         */
00589     typedef typename NumericTraits<ValueType>::RealPromote result_type;
00590     
00591         /** \deprecated use first_argument_type, second_argument_type, result_type
00592         */
00593     typedef ValueType value_type;
00594     
00595         /** Calculate the gradient magnitude form given RGB components.
00596             The function returns 
00597             
00598             \f[ \sqrt{|\nabla red|^2 + |\nabla green|^2 + |\nabla blue|^2}
00599             \f]
00600             
00601             where \f$|\nabla red|^2\f$ is defined by <TT>gx.red()*gx.red() + gy.red()*gy.red()</TT>.
00602             
00603             <TT>ValueType</TT> (the RGB's component type) must support addition, multiplication, 
00604             abd <TT>sqrt()</TT>.
00605         */
00606     result_type 
00607     operator()(first_argument_type const & gx, second_argument_type const & gy) const
00608     {
00609         return VIGRA_CSTD::sqrt(gx.red()*gx.red() + gx.green()*gx.green() +
00610                     gx.blue()*gx.blue() + gy.red()*gy.red() + 
00611                     gy.green()*gy.green() + gy.blue()*gy.blue());
00612     }
00613 };
00614 
00615 //@}
00616 
00617 } // namespace vigra
00618 
00619 #endif // VIGRA_COMBINEIMAGES_HXX

© Ullrich Köthe (koethe@informatik.uni-hamburg.de)
Cognitive Systems Group, University of Hamburg, Germany

html generated using doxygen and Python
VIGRA 1.2.0 (7 Aug 2003)