00001 #ifndef Impala_Core_Array_Trait_M9poRGBw_h 00002 #define Impala_Core_Array_Trait_M9poRGBw_h 00003 00004 #include "Core/Array/Pattern/Categories.h" 00005 #include "Core/Array/Element/E1Sqrt.h" 00006 00007 namespace Impala 00008 { 00009 namespace Core 00010 { 00011 namespace Array 00012 { 00013 namespace Trait 00014 { 00015 00016 00019 template<class DstArrayT, class SrcArrayT> 00020 class M9poRGBw 00021 { 00022 public: 00024 typedef Pattern::TagTransInVar TransVarianceCategory; 00025 00027 typedef Pattern::TagCallValue CallCategory; 00028 00029 typedef typename DstArrayT::ArithType DstArithT; 00030 typedef typename SrcArrayT::ArithType SrcArithT; 00031 00033 M9poRGBw() 00034 { 00035 } 00036 00038 DstArithT 00039 DoIt(const SrcArithT& R, const SrcArithT& G, const SrcArithT& B, 00040 const SrcArithT& Rx, const SrcArithT& Gx, const SrcArithT& Bx, 00041 const SrcArithT& Ry, const SrcArithT& Gy, const SrcArithT& By) 00042 { 00043 SrcArithT I = (R*R+G*G+B*B); 00044 SrcArithT rrx = (Rx*(G+B)-R*(Gx+Bx))/I; 00045 SrcArithT rry = (Ry*(G+B)-R*(Gy+By))/I; 00046 SrcArithT ggx = (Gx*(R+B)-G*(Rx+Bx))/I; 00047 SrcArithT ggy = (Gy*(R+B)-G*(Ry+By))/I; 00048 SrcArithT bbx = (Bx*(G+R)-B*(Gx+Rx))/I; 00049 SrcArithT bby = (By*(G+R)-B*(Gy+Ry))/I; 00050 00051 return Element::E1Sqrt(rrx*rrx+rry*rry+ggx*ggx+ggy*ggy+bbx*bbx+bby*bby); 00052 } 00053 00054 }; 00055 00056 } // namespace Trait 00057 } // namespace Array 00058 } // namespace Core 00059 } // namespace Impala 00060 00061 #endif