Standard Hough Circle Detection

asked 2015-07-31 11:23:01 -0600

Nbb gravatar image

Hello forum,

Ive been trying to write the code for the standard hough circle detection but have not succeded. The code (very simple) is shown below. Basically i perform canny edge detection and then loop through the output and draw a circle when the pixel is not a zero.

int main(int argc, char** argv)
{

image = imread("image.png",CV_LOAD_IMAGE_GRAYSCALE);
image.copyTo(output);

Canny(output, output, 100, 200, 3);

Mat drawing = Mat::zeros(image.size(), CV_8UC1);

for (int i = 0; i < output.rows; i++)
    for (int j = 0; j < output.cols; j++)
        if (output.at<uchar>(i, j) != 0) circle(drawing, Point(i, j), 4, 10, 1, 8, 0);
}

The problem is, i thought that when 2 circles are drawn overlapping each other, the intersecting pixels would be "brighter". I dont think I should draw each circle on a separate matrix to be added after the double for loop so is there anyway I can write the standard HCT without having too many matrices ?

Haziq

edit retag flag offensive close merge delete

Comments

I don't understand your question. If you draw 2 circles with cv::circle() the last one will overwrite the pixel value which intersects with the first one with it's cv::Scalar() value.

For drawing circles you get from cv::HoughCircles() see the example here.

Your code example makes no sense in relation to cv::HoughCircles() because I see no cv::HoughCircles().

matman gravatar imagematman ( 2015-08-01 12:02:15 -0600 )edit