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

| vigra/combineimages.hxx |
--- | --- | ---

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