1

While using hough circle, I didn't quite understand how to define the parameters for hough circles? I also don't even know what the parameters they signify. As far as I know

  • image: It is the source image
  • method: It is the process it uses to detect the circles,(are there any other than hough gradient)
  • minDist: is the min. distance between two centres of a circle
  • minRadius: It the min radius of the circles
  • maxRadius: It is the max radius

The rest of the parameters I don't even understand. Can someone help to explain this to me.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • See https://docs.opencv.org/4.1.1/dd/d1a/group__imgproc__feature.html#ga47849c3be0d0406ad3ca45db65a25d2d – fmw42 Nov 29 '19 at 20:12

1 Answers1

1

Good question!

This is an example of HoughCircles() function from opencv-python tutorials. Lets look at it in details

HoughCircles(image, method, dp, minDist[, param1[, param2[, minRadius[, maxRadius]]]]])

image

This is the input image you want to detect circles from. It's strongly recommended that the image is grayscaled because HoughCircles() uses Canny() function to detect edges in image.

method

This is the mathematical formula used to find circles. The only available formula in HoughCircle is cv2.HOUGH_GRADIENT so you don't have other choice but using it.

dp

Check out this answer here. If you couldn't understand it don't worry. Hough Transform is broad subjet and I advise you to research it more in detail if you want to know what this variable mean, but anyway, this variable should be between 0 and 2 and is of type double, so try using numbers like 0.6 or 1.3.

minDist

This is the minimum distance between the center of circles to be detected. How close are the circles in your image? Do you want the function to detect closely connected circles or far between circles?

param1 and param2

As mentioned before, HoughCircles() internally uses Canny() function. These parameters specify how aggressively you want to detect the edges.

The thresholder used in the Canny operator uses a method called "hysteresis". Most thresholders used a single threshold limit, which means if the edge values fluctuate above and below this value the line will appear broken (commonly referred to as ``streaking''). Hysteresis counters streaking by setting an upper and lower edge value limit. Considering a line segment, if a value lies above the upper threshold limit it is immediately accepted. If the value lies below the low threshold it is immediately rejected. Points which lie between the two limits are accepted if they are connected to pixels which exhibit strong response.

minRadius and maxRadius

The size of circle is represented by its radius. The bigger the radius the bigger the circle and vice versa. These parameters specify the range of sizes of the circles you want to detect.

Finally

When you're using HoughCircles() and other similar functions, a lot of time you will spend will be on tuning these parameters to find the best combination of numbers to detect the circles in your image. So don't be frustrated if you think your parameters are wrong.

O Yahya
  • 366
  • 2
  • 7