libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd cvd_src/nonmax_suppression.cxx cvd/nonma...


From: Edward Rosten
Subject: [libcvd-members] libcvd cvd_src/nonmax_suppression.cxx cvd/nonma...
Date: Thu, 22 Nov 2007 00:52:01 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        07/11/22 00:52:01

Modified files:
        cvd_src        : nonmax_suppression.cxx 
        cvd            : nonmax_suppression.h 

Log message:
        Strict version of nonmax suppression: points have to be larger (rather
        than at least as large) as neighbours. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/nonmax_suppression.cxx?cvsroot=libcvd&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/nonmax_suppression.h?cvsroot=libcvd&r1=1.2&r2=1.3

Patches:
Index: cvd_src/nonmax_suppression.cxx
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/nonmax_suppression.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cvd_src/nonmax_suppression.cxx      15 Aug 2007 17:08:50 -0000      1.4
+++ cvd_src/nonmax_suppression.cxx      22 Nov 2007 00:52:00 -0000      1.5
@@ -13,8 +13,11 @@
 // fast_nonmax_t is templated so you can have either of:
 //     1: A vector of ImageRefs of the nonmax corners
 //     2: A vector of <ImageRef, int> pairs of the corners and their scores.
+// And
+//  1: Non-strict (neighbours of the same score allowed)
+//  2: Strict (must be larger than the neighbours)
 //     It's internal, the user-visible functions instantiate it below..
-template<class Score, class ReturnType, class Collector>
+template<class Score, class ReturnType, class Collector, class Test>
 inline void nonmax_suppression_t(const vector<ImageRef>& corners, const 
vector<Score>& scores, vector<ReturnType>& nonmax_corners)
 {
        nonmax_corners.clear();
@@ -53,12 +56,12 @@
                        
                //Check left 
                if(i > 0)
-                       if(corners[i-1] == pos-ImageRef(1,0) && scores[i-1] > 
score)
+                       if(corners[i-1] == pos-ImageRef(1,0) && 
Test::Compare(scores[i-1], score))
                                continue;
                        
                //Check right
                if(i < (sz - 1))
-                       if(corners[i+1] == pos+ImageRef(1,0) && scores[i+1] > 
score)
+                       if(corners[i+1] == pos+ImageRef(1,0) && 
Test::Compare(scores[i+1], score))
                                continue;
                        
                //Check above (if there is a valid row above)
@@ -77,7 +80,7 @@
                        for(int i=point_above; corners[i].y < pos.y && 
corners[i].x <= pos.x + 1; i++)
                        {
                                int x = corners[i].x;
-                               if( (x == pos.x - 1 || x ==pos.x || x == 
pos.x+1) && scores[i] > score)
+                               if( (x == pos.x - 1 || x ==pos.x || x == 
pos.x+1) && Test::Compare(scores[i], score))
                                        goto cont;
                        }
                        
@@ -96,7 +99,7 @@
                        for(int i=point_below; i < sz && corners[i].y == 
pos.y+1 && corners[i].x <= pos.x + 1; i++)
                        {
                                int x = corners[i].x;
-                               if( (x == pos.x - 1 || x ==pos.x || x == 
pos.x+1) && scores[i] > score)
+                               if( (x == pos.x - 1 || x ==pos.x || x == 
pos.x+1) && Test::Compare(scores[i],score))
                                        goto cont;
                        }
                }
@@ -108,6 +111,23 @@
        }
 }
        
+
+struct Greater
+{
+       static bool Compare(int a, int b)
+       {
+               return a > b;
+       }       
+};
+
+struct GreaterEqual
+{
+       static bool Compare(int a, int b)
+       {
+               return a >= b;
+       }       
+};
+
 // The two collectors which either return just the ImageRef or the 
<ImageRef,int> pair
 struct collect_pos
 {
@@ -120,14 +140,19 @@
 };
 
 // The callable functions
+void nonmax_suppression_strict(const vector<ImageRef>& corners, const 
vector<int>& scores, vector<ImageRef>& nonmax_corners)
+{
+       nonmax_suppression_t<int, ImageRef, collect_pos, GreaterEqual>(corners, 
scores, nonmax_corners);
+}
+
 void nonmax_suppression(const vector<ImageRef>& corners, const vector<int>& 
scores, vector<ImageRef>& nonmax_corners)
 {
-       nonmax_suppression_t<int, ImageRef, collect_pos>(corners, scores, 
nonmax_corners);
+       nonmax_suppression_t<int, ImageRef, collect_pos, Greater>(corners, 
scores, nonmax_corners);
 }
 
 void nonmax_suppression_with_scores(const vector<ImageRef>& corners, const 
vector<int>& scores, vector<pair<ImageRef,int> >& nonmax_corners)
 {
-       nonmax_suppression_t<int, pair<ImageRef,int> , collect_score>(corners, 
scores, nonmax_corners);
+       nonmax_suppression_t<int, pair<ImageRef,int> , collect_score, 
Greater>(corners, scores, nonmax_corners);
 }
 
 

Index: cvd/nonmax_suppression.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/nonmax_suppression.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- cvd/nonmax_suppression.h    23 Jul 2007 20:43:22 -0000      1.2
+++ cvd/nonmax_suppression.h    22 Nov 2007 00:52:00 -0000      1.3
@@ -8,6 +8,16 @@
 namespace CVD
 {
        /**Perform nonmaximal suppression on a set of features, in a 3 by 3 
window.
+          The test is strict: a point must be greater than its neighbours.
+
+       @param corners The corner locations
+       @param scores  The corners' scores
+       @param max_corners The locally maximal corners.
+       @ingroup gVision
+       */
+       void nonmax_suppression_strict(const std::vector<ImageRef>& corners, 
const std::vector<int>& scores, std::vector<ImageRef>& nmax_corners);
+       /**Perform nonmaximal suppression on a set of features, in a 3 by 3 
window.
+          The test is non-strict: a point must be at least as large as its 
neighbours.
 
        @param corners The corner locations
        @param scores  The corners' scores
@@ -18,6 +28,7 @@
 
 
        /**Perform nonmaximal suppression on a set of features, in a 3 by 3 
window.
+          Non strict.
 
        @param corners The corner locations
        @param scores  The corners' scores




reply via email to

[Prev in Thread] Current Thread [Next in Thread]