00001 #ifndef Impala_Core_Test_TestColorSegmentation_h
00002 #define Impala_Core_Test_TestColorSegmentation_h
00003
00004 #include "Core/Test/TestImage.h"
00005 #include "Core/Array/ColorSegmentation.h"
00006
00007 #pragma warning (disable : 4800)
00008
00009 namespace Impala
00010 {
00011 namespace Core
00012 {
00013 namespace Test
00014 {
00015
00016
00017 class TestColorSegmentation : public TestImage
00018 {
00019 public:
00020 typedef Array::ColorSegmentationAlgorithm ColorSegmentationAlgorithm;
00021 typedef Array::ColorSegmentationInvariant ColorSegmentationInvariant;
00022
00023 TestColorSegmentation(String srcName, ColorSegmentationAlgorithm segAlg,
00024 ColorSegmentationInvariant invType,
00025 double fraction, double threshold, bool useGauss)
00026 {
00027 mTestNameBase = "ColorSegmentation";
00028 mSrcName = srcName;
00029 mSegAlg = segAlg;
00030 mInvType = invType;
00031 mFraction = fraction;
00032 mThreshold = threshold;
00033 mUseGauss = useGauss;
00034 }
00035
00036 virtual void
00037 Run()
00038 {
00039 Array2dVec3Real64* src = OpenSrcArrayAsVec3Real64(mSrcName);
00040 Array2dVec3UInt8* res = 0;
00041 Array::ColorSegmentation(res, src, mSegAlg, mInvType, mFraction,
00042 mThreshold, mUseGauss, 0);
00043
00044 int id = mImSet->GetFileId(mSrcName);
00045 String suffix = FileNameCtor("", mTestNameBase, mSegAlg, mInvType,
00046 mFraction, mThreshold, mUseGauss, ".raw");
00047 if (1)
00048 {
00049 Compare(res, mImSet->GetFilePathReference(id, suffix, false, false));
00050 }
00051 else
00052 {
00053 WriteRaw(res, mImSet->GetFilePathReference(id, suffix, true, false),
00054 mImSet->GetDatabase(), true);
00055 }
00056
00057 delete src;
00058 delete res;
00059 }
00060
00061 virtual String
00062 Name() const
00063 {
00064 return FileNameCtor(mTestNameBase, mSrcName, mSegAlg, mInvType,
00065 mFraction, mThreshold, mUseGauss, "");
00066 }
00067
00068 private:
00069
00070 String mTestNameBase;
00071 String mSrcName;
00072 ColorSegmentationAlgorithm mSegAlg;
00073 ColorSegmentationInvariant mInvType;
00074 double mFraction;
00075 double mThreshold;
00076 bool mUseGauss;
00077
00078 };
00079
00080
00081 static TestBase* gColorSegmentationSuite[] =
00082 {
00083
00084
00085
00086
00087
00088 new TestColorSegmentation("beach.jpg", Array::TextureAddZero,
00089 Array::E, 0.01, 6.0, false),
00090
00091
00092
00093
00094
00095 (TestBase*)0
00096 };
00097
00098 }
00099 }
00100 }
00101
00102 #endif