[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd Makefile.in cvd_src/nonmax_suppression.c... [FAS
From: |
Edward Rosten |
Subject: |
[libcvd-members] libcvd Makefile.in cvd_src/nonmax_suppression.c... [FAST_cleanup] |
Date: |
Wed, 27 Jun 2007 22:26:53 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Branch: FAST_cleanup
Changes by: Edward Rosten <edrosten> 07/06/27 22:26:53
Modified files:
. : Makefile.in
Added files:
cvd_src : nonmax_suppression.cxx
cvd : nonmax_suppression.h
Log message:
More generic nonmax-suppression.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/nonmax_suppression.cxx?cvsroot=libcvd&only_with_tag=FAST_cleanup&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/nonmax_suppression.h?cvsroot=libcvd&only_with_tag=FAST_cleanup&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/libcvd/Makefile.in?cvsroot=libcvd&only_with_tag=FAST_cleanup&r1=1.52&r2=1.52.2.1
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/libcvd/libcvd/Makefile.in,v
retrieving revision 1.52
retrieving revision 1.52.2.1
diff -u -b -r1.52 -r1.52.2.1
--- Makefile.in 2 Mar 2007 15:31:19 -0000 1.52
+++ Makefile.in 27 Jun 2007 22:26:53 -0000 1.52.2.1
@@ -101,6 +101,7 @@
cvd_src/fast_corner.o \
cvd_src/faster_corner.o \
cvd_src/convolution.o
\
+ cvd_src/nonmax_suppression.o \
cvd_src/fast/address@hidden@address@hidden@.o
\
cvd_src/fast/address@hidden@address@hidden@.o
\
cvd_src/fast/address@hidden@address@hidden@.o
\
Index: cvd_src/nonmax_suppression.cxx
===================================================================
RCS file: cvd_src/nonmax_suppression.cxx
diff -N cvd_src/nonmax_suppression.cxx
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cvd_src/nonmax_suppression.cxx 27 Jun 2007 22:26:52 -0000 1.1.2.1
@@ -0,0 +1,133 @@
+#include <cvd/image_ref.h>
+#include <vector>
+
+using namespace std;
+
+namespace CVD
+{
+
+
+//This function has been moved from fast_corner.cxx. Look there
+//for the old ChangeLog.
+// 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.
+// It's internal, the user-visible functions instantiate it below..
+template<class Score, class ReturnType, class Collector>
+inline void nonmax_suppression_t(const vector<ImageRef>& corners, const
vector<Score>& scores, vector<ReturnType>& nonmax_corners)
+{
+ nonmax_corners.clear();
+ nonmax_corners.reserve(corners.size());
+
+ if(corners.size() < 1)
+ return;
+
+
+ // Find where each row begins
+ // (the corners are output in raster scan order). A beginning of -1
signifies
+ // that there are no corners on that row.
+ int last_row = corners.back().y;
+ vector<int> row_start(last_row, -1);
+
+ int prev_row = -1;
+ for(unsigned int i=0; i< corners.size(); i++)
+ if(corners[i].y != prev_row)
+ {
+ row_start[corners[i].y] = i;
+ prev_row = corners[i].y;
+ }
+
+
+ //Point above points (roughly) to the pixel above the one of interest,
if there
+ //is a feature there.
+ int point_above = 0;
+ int point_below = 0;
+
+ const unsigned int sz = corners.size();
+
+ for(unsigned int i=0; i < sz; i++)
+ {
+ Score score = scores[i];
+ ImageRef pos = corners[i];
+
+ //Check left
+ if(i > 0)
+ if(corners[i-1] == pos-ImageRef(1,0) && scores[i-1] >
score)
+ continue;
+
+ //Check right
+ if(i < (sz - 1))
+ if(corners[i+1] == pos+ImageRef(1,0) && scores[i+1] >
score)
+ continue;
+
+ //Check above (if there is a valid row above)
+ if(pos.y != 0 && row_start[pos.y - 1] != -1)
+ {
+ //Make sure that current point_above is one
+ //row above.
+ if(corners[point_above].y < pos.y - 1)
+ point_above = row_start[pos.y-1];
+
+ //Make point_above point to the first of the pixels
above the current point,
+ //if it exists.
+ for(; corners[point_above].y < pos.y &&
corners[point_above].x < pos.x - 1; point_above++);
+
+
+ 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)
+ goto cont;
+ }
+
+ }
+
+ //Check below (if there is anything below)
+ if(pos.y != last_row-1 && row_start[pos.y + 1] != -1 &&
point_below < sz) //Nothing below
+ {
+ if(corners[point_below].y < pos.y + 1)
+ point_below = row_start[pos.y+1];
+
+ // Make point below point to one of the pixels belowthe
current point, if it
+ // exists.
+ for(; point_below < sz && corners[point_below].y ==
pos.y+1 && corners[point_below].x < pos.x - 1; point_below++);
+
+ 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)
+ goto cont;
+ }
+ }
+
+
nonmax_corners.push_back(Collector::collect(corners[i],scores[i]));
+
+ cont:
+ ;
+ }
+}
+
+// The two collectors which either return just the ImageRef or the
<ImageRef,int> pair
+struct collect_pos
+{
+ static inline ImageRef collect(const ImageRef& pos, int score){return
pos;}
+};
+
+struct collect_score
+{
+ static inline pair<ImageRef, int> collect(const ImageRef& pos, int
score){return make_pair(pos,score);}
+};
+
+// The callable functions
+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);
+}
+
+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);
+}
+
+
+}
Index: cvd/nonmax_suppression.h
===================================================================
RCS file: cvd/nonmax_suppression.h
diff -N cvd/nonmax_suppression.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ cvd/nonmax_suppression.h 27 Jun 2007 22:26:53 -0000 1.1.2.1
@@ -0,0 +1,28 @@
+#ifndef CVD_NONMAX_SUPPRESSION_H
+#define CVD_NONMAX_SUPPRESSION_H
+
+#include <vector>
+#include <cvd/image_ref.h>
+
+namespace CVD
+{
+ /**Perform nonmaximal suppression on a set of features.
+
+ @param corners The corner locations
+ @param scores The corners' scores
+ @param max_corners The locally maximal corners.
+ @ingroup gVision
+ */
+ void nonmax_suppression(const vector<ImageRef>& corners, const
vector<int>& scores, vector<ImageRef>& nmax_corners);
+
+
+ /**Perform nonmaximal suppression on a set of features.
+
+ @param corners The corner locations
+ @param scores The corners' scores
+ @param max_corners The locally maximal corners, and their scores.
+ @ingroup gVision
+ */
+ void nonmax_suppression_with_scores(const vector<ImageRef>& corners,
const vector<int>& socres, vector<pair<ImageRef,int> >& max_corners);
+
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd Makefile.in cvd_src/nonmax_suppression.c... [FAST_cleanup],
Edward Rosten <=