libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd/cvd/internal convert_pixel_types.h


From: Gerhard Reitmayr
Subject: [libcvd-members] libcvd/cvd/internal convert_pixel_types.h
Date: Thu, 27 Jul 2006 11:15:43 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Gerhard Reitmayr <gerhard>      06/07/27 11:15:42

Modified files:
        cvd/internal   : convert_pixel_types.h 

Log message:
        added SumOfSquares pixel conversion

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/convert_pixel_types.h?cvsroot=libcvd&r1=1.10&r2=1.11

Patches:
Index: convert_pixel_types.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/convert_pixel_types.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- convert_pixel_types.h       16 May 2006 13:23:52 -0000      1.10
+++ convert_pixel_types.h       27 Jul 2006 11:15:42 -0000      1.11
@@ -158,6 +158,19 @@
     }
   };  
 
+  template <class P, class Scalar> struct SumOfSquares {
+    static inline void convert(const P& from, Scalar& to) {
+      typedef typename Pixel::Component<P>::type T;
+      double sum = Pixel::Component<P>::get(from,0);
+      sum *= sum;
+      for (unsigned int i=1; i<Pixel::Component<P>::count; i++) {
+    double w = Pixel::Component<P>::get(from,i);
+    sum += w*w;
+      }
+      to = scalar_convert<Scalar,T,double>(sum);
+    }
+  };
+
   template <class Scalar, class Vec> struct Replicate {
     static inline void convert(const Scalar& from, Vec& to) {
       typedef typename Pixel::Component<Vec>::type T;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]