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: Ethan Eade
Subject: [Libcvd-members] libcvd/cvd/internal convert_pixel_types.h
Date: Tue, 16 May 2006 13:23:52 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Branch:         
Changes by:     Ethan Eade <address@hidden>     06/05/16 13:23:52

Modified files:
        cvd/internal   : convert_pixel_types.h 

Log message:
        Added AverageAbs pixel converter (uses average absolute value of 
components
        as intensity).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/libcvd/cvd/internal/convert_pixel_types.h.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: libcvd/cvd/internal/convert_pixel_types.h
diff -u libcvd/cvd/internal/convert_pixel_types.h:1.9 
libcvd/cvd/internal/convert_pixel_types.h:1.10
--- libcvd/cvd/internal/convert_pixel_types.h:1.9       Fri May  5 16:57:38 2006
+++ libcvd/cvd/internal/convert_pixel_types.h   Tue May 16 13:23:52 2006
@@ -133,6 +133,18 @@
     }
   };  
 
+  template <class P, class Scalar> struct AverageAbs {
+    static inline void convert(const P& from, Scalar& to) {
+      typedef typename Pixel::Component<P>::type T;
+      typedef typename Pixel::traits<T>::wider_type sum_type;
+      sum_type sum = CVD::abs(Pixel::Component<P>::get(from,0));
+      for (unsigned int i=1; i<Pixel::Component<P>::count; i++) {
+         sum += CVD::abs(Pixel::Component<P>::get(from,i));
+      }
+      to = scalar_convert<Scalar,T,sum_type>(sum/Pixel::Component<P>::count);
+    }
+  };  
+
   template <class P, class Scalar> struct L2Norm {
     static inline void convert(const P& from, Scalar& to) {
       typedef typename Pixel::Component<P>::type T;




reply via email to

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