Create a grid over image without template matching
Hi all,
I have this image:
I was wondering if there was an efficient way of using openCV to create a grid across the image such that the centre of each grid contains a circle, and if was possible to do this without template matching. I also would like the grid to contain the half circles at the edges. I'm trying to learn openCV and could only come up with manual calculation to perform this task without pattern matching.
Any help would be appreciated! Thank you very much!
Circles can be detected with
HoughCircles()
function. See this tutorial.To get the grid, you will have to sort the position of detected circles.
Thank you for replying! I don't need to detect circles, I need a grid that would contain a circle.
Find contour to solve it?
I tried that already, but the bounding box sizes are sometimes different, even if they're off by just a pixel or so. Is there a way to get equal sized grids this way? I'm sorry if I'm being difficult!
I think you should use findcontour. After, you add more additions such as: close contour or not, area, ... to get fit contours.
you could project it to the image's x/y axes using reduce(), and then find an average distance between the peaks