Commit c4f88b06 authored by lluis's avatar lluis

removed some unnecessary ERStat members as they are easily computable from others

parent 43e7e6e4
...@@ -79,13 +79,8 @@ public: ...@@ -79,13 +79,8 @@ public:
Rect rect; Rect rect;
double raw_moments[2]; //!< order 1 raw moments to derive the centroid double raw_moments[2]; //!< order 1 raw moments to derive the centroid
double central_moments[3]; //!< order 2 central moments to construct the covariance matrix double central_moments[3]; //!< order 2 central moments to construct the covariance matrix
std::deque<int> *crossings;//!< horizontal crossings std::deque<int> *crossings;//!< horizontal crossings
float med_crossings; //!< median of the crossings at three different height levels
//! 1st stage features
float aspect_ratio;
float compactness;
float num_holes;
float med_crossings;
//! 2nd stage features //! 2nd stage features
float hole_area_ratio; float hole_area_ratio;
......
...@@ -611,11 +611,6 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) ...@@ -611,11 +611,6 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child)
parent->central_moments[1] += child->central_moments[1]; parent->central_moments[1] += child->central_moments[1];
parent->central_moments[2] += child->central_moments[2]; parent->central_moments[2] += child->central_moments[2];
// child region done, we can calculate 1st stage features from the incrementally computable descriptors
child->aspect_ratio = (float)(child->rect.width)/(child->rect.height);
child->compactness = sqrt((float)(child->area))/child->perimeter;
child->num_holes = (float)(1-child->euler);
vector<int> m_crossings; vector<int> m_crossings;
m_crossings.push_back(child->crossings->at((int)(child->rect.height)/6)); m_crossings.push_back(child->crossings->at((int)(child->rect.height)/6));
m_crossings.push_back(child->crossings->at((int)3*(child->rect.height)/6)); m_crossings.push_back(child->crossings->at((int)3*(child->rect.height)/6));
...@@ -1004,7 +999,11 @@ ERClassifierNM1::ERClassifierNM1() ...@@ -1004,7 +999,11 @@ ERClassifierNM1::ERClassifierNM1()
double ERClassifierNM1::eval(const ERStat& stat) double ERClassifierNM1::eval(const ERStat& stat)
{ {
//Classify //Classify
float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings}; float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio
sqrt((float)(stat.area))/stat.perimeter, // compactness
(float)(1-stat.euler), //number of holes
stat.med_crossings};
vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) ); vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) );
float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true ); float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true );
...@@ -1038,8 +1037,12 @@ ERClassifierNM2::ERClassifierNM2() ...@@ -1038,8 +1037,12 @@ ERClassifierNM2::ERClassifierNM2()
double ERClassifierNM2::eval(const ERStat& stat) double ERClassifierNM2::eval(const ERStat& stat)
{ {
//Classify //Classify
float arr[] = {0,stat.aspect_ratio, stat.compactness, stat.num_holes, stat.med_crossings, float arr[] = {0,(float)(stat.rect.width)/(stat.rect.height), // aspect ratio
stat.hole_area_ratio, stat.convex_hull_ratio, stat.num_inflexion_points}; sqrt((float)(stat.area))/stat.perimeter, // compactness
(float)(1-stat.euler), //number of holes
stat.med_crossings, stat.hole_area_ratio,
stat.convex_hull_ratio, stat.num_inflexion_points};
vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) ); vector<float> sample (arr, arr + sizeof(arr) / sizeof(arr[0]) );
float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true ); float votes = boost.predict( Mat(sample), Mat(), Range::all(), false, true );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment