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

Color64Extractor.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_ImageSet_Color64Extractor_h
00002 #define Impala_Core_ImageSet_Color64Extractor_h
00003 
00004 // extract color 64 bin features, provided by xirong.
00005 // color64: 44-d color correlgoram, 14-d color texture moment, and 6-d RGB color moment
00006 
00007 #include "Core/ImageSet/Reporter.h"
00008 #include "Core/Vector/VectorTem.h"
00009 #include "Core/Feature/FeatureTable.h"
00010 #include "Core/Feature/Color64.h"
00011 //#include "Core/Stream/SeqConvKernel.h"
00012 //#include "Core/Array/RGB2Gray.h"
00013 
00014 namespace Impala
00015 {
00016 namespace Core
00017 {
00018 namespace ImageSet
00019 {
00020 
00021 class Color64Extractor : public Listener
00022 {
00023 
00024 protected:
00025 
00026     typedef Vector::VectorTem<Real64> VectorReal64;
00027 
00028 public:
00029 
00030     Color64Extractor(Reporter* reporter, 
00031         CmdOptions& options, CString featureName, int binCount)
00032     {
00033         mReporter = reporter;
00034         mFeatureName = featureName;
00035         mBinCount = binCount;
00036         Feature::FeatureDefinition def(GetFeatureName());
00037         mHistogramTable = new Feature::FeatureTable(def, 1000, GetBinCount());
00038 
00039         m_verbose = FALSE;
00040         m_verbose2 = FALSE;
00041     }
00042 
00043     Color64Extractor(Reporter* reporter, CmdOptions& options)
00044     {
00045         mReporter = reporter;
00046         mFeatureName = "color64"; // default feature name
00047         mBinCount = 64;
00048         Feature::FeatureDefinition def(GetFeatureName());
00049         mHistogramTable = new Feature::FeatureTable(def, 1000, GetBinCount());
00050 
00051         m_verbose = FALSE;
00052         m_verbose2 = FALSE;
00053         //m_verbose = TRUE;
00054         //m_verbose2 = TRUE;
00055         
00056     }
00057 
00058     virtual 
00059     ~Color64Extractor()
00060     {
00061         delete mHistogramTable;
00062     }
00063 
00064     String
00065     GetFeatureName() const
00066     {
00067         return mFeatureName;
00068     }
00069 
00070     virtual void
00071     //HandleNewFile(ImageSet* is, int fileId, Stream::RgbDataSrc* src)
00072     HandleNewFile(ImageSet* is, int fileId, Array::Array2dVec3UInt8* im)
00073     {
00074         if (!im)
00075         {
00076             ILOG_ERROR("Couldn't load image for fileId " << fileId);
00077             return;
00078         }
00079 
00080         if (m_verbose)
00081         {
00082             std::cout << "Current File No. = " << fileId << std::endl;
00083         }
00084 
00085 #ifdef __BITMAP_FUNC__
00086         Core::Feature::Bitmap bitmap;
00087         bitmap.SaveRgb2BitmapFile("rgb_Color64Extractor.bmp", im->CPB(), im->CW(), im->CH());
00088 
00089         Impala::String fName = "rgb_Color64Extractor.png";
00090         Array::WritePng(im, fName, is->GetDatabase());
00091 #endif
00092 
00093         VectorReal64 histogram(mBinCount);
00094                 
00095         Core::Feature::Color64* pExtractor = new Core::Feature::Color64(mFeatureName);
00096         pExtractor->Extract(im, histogram);
00097 
00098         Quid quid = is->GetQuidImage(fileId);
00099         mHistogramTable->Add(quid, histogram);
00100 
00101         delete pExtractor;
00102 
00103         ILOG_DEBUG("... done file " << fileId);
00104 
00105     }
00106 
00107     virtual void
00108     //HandleDoneDir(ImageSet* is, int dirId, Stream::RgbDataSrc* src)
00109     HandleDoneDir(ImageSet* is, int dirId)
00110     {
00111         bool binary = true;
00112         Feature::FeatureDefinition def = mHistogramTable->GetFeatureDefinition();
00113         //std::string fName = is->GetFilePathFeatureData("Keyframes", def, dirId, false, -1, true, false);
00114         std::string fName = is->GetFilePathFeatureData(def, dirId, false, -1, true, false);
00115         
00116         if (!fName.empty())
00117             Table::Write(mHistogramTable, fName, is->GetDatabase(), binary);
00118         mHistogramTable->SetSize(0);
00119 
00120         ILOG_DEBUG("... done dir " << dirId);
00121     }
00122 
00123 protected:
00124 
00125     int
00126     GetBinCount() const
00127     {
00128         return mBinCount;
00129     }
00130 
00131 private:
00132 
00133     //static const int BINS_PER_CHANNEL = 32;
00134 
00135     Reporter*              mReporter;
00136     String                 mFeatureName;
00137     int                    mBinCount;
00138     Feature::FeatureTable* mHistogramTable;
00139 
00140     BOOL                   m_verbose;
00141     BOOL                   m_verbose2; // for dedug only; more detailed info
00142 
00143     ILOG_VAR_DECL;
00144 };
00145 
00146 ILOG_VAR_INIT(Color64Extractor, Impala.Core.ImageSet);
00147 
00148 } // namespace ImageSet
00149 } // namespace Core
00150 } // namespace Impala
00151 
00152 #endif

Generated on Thu Jan 13 09:04:30 2011 for ImpalaSrc by  doxygen 1.5.1