1

I have an image of a dice. I want to count the number of dots. I first tried just separating it using the color of the dots and reading the number of connected paths. But it is failing since the photo contains a tilted image of the side face also. So I tried Hough circles.

circles = cv2.HoughCircles(detected_edges, cv2.cv.CV_HOUGH_GRADIENT, 1, 10, circles, 105, 10, 10, 15)

This is the code I tried. But it is not detecting the correct circles. When I looked the diameter of the dots, it was around 12-15 pixels and the minimum distance between the pixels were 14-16 pixels. I am not sure about setting the param1 and param2 values. As I saw in the documentation, I used 105 since it worked for Canny method. Can somone help me in resolving this?

Sreeja
  • 35
  • 1
  • 1
  • 7
  • I went through [this](http://stackoverflow.com/questions/10716464/what-are-the-correct-usage-parameter-values-for-houghcircles-in-opencv-for-iris/10718967#10718967) and [this](http://stackoverflow.com/questions/11276390/houghcircles-parameters-to-recognise-balls). But it didn't help me. – Sreeja Apr 29 '13 at 10:03
  • Why don't you share the picture of your dice, so that your test-case becomes more clear to us. – Vishal Apr 29 '13 at 10:07
  • I don't have enough credits to post an image. – Sreeja Apr 29 '13 at 10:13
  • Ok. I haven't seen your image. How about you first detect the top-face of your dice, and use your first technique for getting the number of dots only in top-face region. – Vishal Apr 29 '13 at 10:18
  • I don't have any idea to selectively detect only the top face, because the position of the dice is not fixed. – Sreeja Apr 29 '13 at 10:31
  • I have shared the test image [here](https://www.dropbox.com/s/nihd5nrj3rpn00n/image.jpeg) – Sreeja Apr 29 '13 at 10:37
  • Hm. If it is sure, that the dice is always lighter than the surrounding region, I would try to find maximums of lightness in the _blurred_ image. Then I would search for dots within a certain radius around these maximums. – Nippey Apr 29 '13 at 11:32
  • Thank you for the hint. I tried your logic and its working fine. But I wish to try hough circles. Any help is really appreciated. – Sreeja May 08 '13 at 03:41
  • I preprocessed the image extracting only the light color of the dice. Then I applied connected component labeling to the result. The application is working fine. But I would wish to know how to implement this using Hough Circles. – Sreeja Sep 05 '13 at 08:09

1 Answers1

0

I would try decreasing your minimum radius to around 5 if your dots have diameter 12-15 pixels and ditto max radius could be smaller e.g. 8 and increase your param2 to around 20. Also are you blurring before applying the detection?