00001 #ifndef Impala_Core_Array_TestEqual_h
00002 #define Impala_Core_Array_TestEqual_h
00003
00004 #include "Core/Array/Pattern/PatBinaryPixOp.h"
00005 #include "Core/Array/Trait/BpoTestEqual.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013
00014
00015 template<class DstArrayT, class Src1ArrayT, class Src2ArrayT>
00016 inline bool
00017 TestEqual(DstArrayT*& dst, Src1ArrayT* src1, Src2ArrayT* src2, double epsilon)
00018 {
00019 ILOG_FUNCTION(Impala.Core.Array.TestEqual);
00020 bool equal = true;
00021 if (src1->CW() != src2->CW())
00022 {
00023 ILOG_DEBUG("TestEqual: width differs: " << src1->CW() << " vs "
00024 << src2->CW());
00025 equal = false;
00026 }
00027 if (src1->CH() != src2->CH())
00028 {
00029 ILOG_DEBUG("TestEqual: height differs: " << src1->CH() << " vs "
00030 << src2->CH());
00031 equal = false;
00032 }
00033 Trait::BpoTestEqual<DstArrayT, Src1ArrayT, Src2ArrayT> bpo(epsilon);
00034 Pattern::PatBinaryPixOp(dst, src1, src2, bpo);
00035 if (bpo.mNrDiff > 0)
00036 {
00037 ILOG_DEBUG("TestEqual found " << bpo.mNrDiff << " differences, in "
00038 << bpo.mNr << " pixels, sum diffs : " << bpo.mSumDiff
00039 << " avg diff : " << bpo.mSumDiff / bpo.mNrDiff
00040 << " avg src1 : " << bpo.mSumSrc1 / bpo.mNr
00041 << " avg src2 : " << bpo.mSumSrc2 / bpo.mNr);
00042 equal = false;
00043 }
00044 return equal;
00045 }
00046
00047 }
00048 }
00049 }
00050
00051 #endif