00001 #ifndef Impala_Core_Feature_Weibull_h
00002 #define Impala_Core_Feature_Weibull_h
00003
00004 #include "Core/Vector/VectorSet.h"
00005 #include "Core/Histogram/ComputeWeibull.h"
00006 #include "Core/Array/InvWiccest.h"
00007 #include "Core/Array/RGB2Intensity.h"
00008 #include "Core/Array/DivVal.h"
00009 #include "Core/Histogram/MakeHistogram1dSet.h"
00010
00011 namespace Impala
00012 {
00013 namespace Core
00014 {
00015 namespace Feature
00016 {
00017
00018
00019 Vector::VectorSet<Core::Array::Array2dScalarReal64>*
00020 Weibull(Core::Array::Array2dVec3UInt8* im, Real64 sigma)
00021 {
00022 typedef Array::Array2dScalarReal64 Array2dScalarReal64;
00023 typedef Vector::VectorTem<Real64> VectorReal64;
00024 typedef Array::ArraySet<Array2dScalarReal64> InvSetType;
00025 typedef Histogram::Histogram1dSet<Array2dScalarReal64> HistSetType;
00026 typedef HistSetType::HistT HistType;
00027 typedef Vector::VectorSet<Array2dScalarReal64> VecSetType;
00028
00029 int histBinCount = 1001;
00030 Real64 histLow = -1;
00031 Real64 histHigh = 1;
00032 bool doRot = false;
00033 bool doC = false;
00034 int borderSize = 15;
00035
00036 Geometry::Rectangle rect(15, 15, im->CW() - 15, im->CH() - 15);
00037 Array::ArraySet<Array2dScalarReal64> invSet;
00038 Array::InvWiccest(invSet, im, doRot, doC, sigma, 3, true);
00039
00040
00041 HistSetType hSet(histLow, histHigh, histBinCount, invSet.Size());
00042 Histogram::MakeHistogram1dSet(&hSet, invSet, rect, true);
00043 VecSetType* res = new VecSetType(true, 2, invSet.Size());
00044 for (int h=0 ; h<hSet.Size() ; h++)
00045 {
00046 VectorReal64 v(2);
00047 Histogram::ComputeWeibull(v, hSet.Hist(h), false, false);
00048 res->AddVector(v);
00049 }
00050
00051 invSet.Delete();
00052 return res;
00053 }
00054
00055
00056 Vector::VectorSet<Core::Array::Array2dScalarReal64>*
00057 WeibullIRGB(Core::Array::Array2dVec3UInt8* im, Real64 sigma, bool doMu = false,
00058 bool doAnderson = false, bool doArjan = false)
00059 {
00060 typedef Array::Array2dScalarReal64 Array2dScalarReal64;
00061 typedef Vector::VectorTem<Real64> VectorReal64;
00062 typedef Array::ArraySet<Array2dScalarReal64> InvSetType;
00063 typedef Histogram::Histogram1dSet<Array2dScalarReal64> HistSetType;
00064 typedef HistSetType::HistT HistType;
00065 typedef Vector::VectorSet<Array2dScalarReal64> VecSetType;
00066
00067 int histBinCount = 1001;
00068 Real64 histLow = -1;
00069 Real64 histHigh = 1;
00070 int borderSize = 15;
00071
00072 int vecSize = (doMu) ? 3 : 2;
00073 if (doAnderson)
00074 vecSize++;
00075 Geometry::Rectangle rect(15, 15, im->CW() - 15, im->CH() - 15);
00076 if (doArjan)
00077 rect = Geometry::Rectangle(5, 5, 240, im->CH() - 5);
00078 Array::ArraySet<Array2dScalarReal64> invSet;
00079 Array::Array2dVec3Real64* imR = 0;
00080 Array::Set(imR, im);
00081 Array::DivVal(imR, imR, Array::Element::Vec3Real64(255, 255, 255));
00082 Array::Array2dScalarReal64* l = 0;
00083 Array::RGB2Intensity(l, imR);
00084 RecGauss(invSet.Array("Lx"), l, sigma, sigma, 1, 0, 3.0);
00085 RecGauss(invSet.Array("Ly"), l, sigma, sigma, 0, 1, 3.0);
00086 std::vector<Array2dScalarReal64*> rgbList;
00087 rgbList = InvCompDer(imR, sigma, 3.0, true);
00088 Array::Set(invSet.Array("Rx"), rgbList[1]);
00089 Array::Set(invSet.Array("Ry"), rgbList[2]);
00090 Array::Set(invSet.Array("Gx"), rgbList[4]);
00091 Array::Set(invSet.Array("Gy"), rgbList[5]);
00092 Array::Set(invSet.Array("Bx"), rgbList[7]);
00093 Array::Set(invSet.Array("By"), rgbList[8]);
00094 Array::ArrayListDelete(&rgbList);
00095
00096
00097 HistSetType hSet(histLow, histHigh, histBinCount, invSet.Size());
00098 Histogram::MakeHistogram1dSet(&hSet, invSet, rect, true);
00099 VecSetType* res = new VecSetType(true, vecSize, invSet.Size());
00100 for (int h=0 ; h<hSet.Size() ; h++)
00101 {
00102 VectorReal64 v(vecSize);
00103 Histogram::ComputeWeibull(v, hSet.Hist(h), doMu, doAnderson);
00104 res->AddVector(v);
00105 }
00106
00107 delete l;
00108 delete imR;
00109 invSet.Delete();
00110 return res;
00111 }
00112
00113
00114 }
00115 }
00116 }
00117
00118 #endif