Commit 332588fc authored by Peter Fischer's avatar Peter Fischer Committed by GitHub

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
parent 7475d23f
...@@ -1112,8 +1112,8 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, ...@@ -1112,8 +1112,8 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
{ {
int base = y*(acols+2) + x; int base = y*(acols+2) + x;
if( adata[base] > acc_threshold && if( adata[base] > acc_threshold &&
adata[base] > adata[base-1] && adata[base] > adata[base+1] && 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-acols-2] && adata[base] >= adata[base+acols+2] )
cvSeqPush(centers, &base); cvSeqPush(centers, &base);
} }
} }
......
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