From 332588fceef68ddf26456a27b5690d514a5c1d52 Mon Sep 17 00:00:00 2001 From: Peter Fischer Date: Wed, 27 Sep 2017 11:47:30 +0200 Subject: [PATCH] Fix bug: non-maximum suppression for hough circle The non-maximum suppression in the Hough accumulator incorrectly ignores maxima that extend over more than one cell, i.e. two neighboring cells both have the same accumulator value. This maximum is dropped completely instead of picking at least one of the entries. This frequently results in obvious circles being missed. The behavior is now changed to be the same as for hough_lines. See also https://github.com/opencv/opencv/issues/4440 --- modules/imgproc/src/hough.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp index 665e9a3af8..d8c028443e 100644 --- a/modules/imgproc/src/hough.cpp +++ b/modules/imgproc/src/hough.cpp @@ -1112,8 +1112,8 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, { int base = y*(acols+2) + x; if( adata[base] > acc_threshold && - adata[base] > adata[base-1] && adata[base] > adata[base+1] && - adata[base] > adata[base-acols-2] && adata[base] > adata[base+acols+2] ) + adata[base] > adata[base-1] && adata[base] >= adata[base+1] && + adata[base] > adata[base-acols-2] && adata[base] >= adata[base+acols+2] ) cvSeqPush(centers, &base); } }