Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

PixStat.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_PixStat_h
00002 #define Impala_Core_Array_PixStat_h
00003 
00004 #include "Core/Array/Pattern/PatInOutOp.h"
00005 #include "Core/Array/Trait/ExportStat.h"
00006 #include "Core/Array/Element/E1Cast.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 
00015 
00016 template<class ArrayT, class ArithT>
00017 inline void
00018 PixStat(ArrayT* im, ArithT* minVal, ArithT* maxVal, ArithT* mean,
00019         ArithT* variance)
00020 {
00021     Trait::ExportStat<ArithT, ArithT> pixOp;
00022     Pattern::PatInOutOp(im, pixOp);
00023     if (minVal)
00024         *minVal = pixOp.mMinVal;
00025     if (maxVal)
00026         *maxVal = pixOp.mMaxVal;
00027     ArithT num = Element::E1Cast(pixOp.mNum, ArithT());
00028     ArithT num1 = num - Element::E1Cast(1, ArithT());
00029     if (mean)
00030         *mean = pixOp.mSum / num;
00031     if (variance)
00032         *variance = (pixOp.mNum == 1) ? Element::E1Cast(0, ArithT())
00033             : (pixOp.mSumSqr - ((pixOp.mSum * pixOp.mSum) / num)) / (num1);
00034 }
00035 
00036 template<class ArrayT, class ArithT>
00037 inline void
00038 PixStatBasic(ArrayT* im, ArithT* nr, ArithT* sum, ArithT* sumSqr, ArithT* sumAbs)
00039 {
00040     Trait::ExportStat<ArithT, ArithT> pixOp;
00041     Pattern::PatInOutOp(im, pixOp);
00042     if (nr)
00043         *nr = Element::E1Cast(pixOp.mNum, ArithT());
00044     if (sum)
00045         *sum = pixOp.mSum;
00046     if (sumSqr)
00047         *sumSqr = pixOp.mSumSqr;
00048     if (sumAbs)
00049         *sumAbs = pixOp.mSumAbs;
00050 }
00051 
00052 } // namespace Array
00053 } // namespace Core
00054 } // namespace Impala
00055 
00056 #endif

Generated on Fri Mar 19 09:30:52 2010 for ImpalaSrc by  doxygen 1.5.1