Revision history [back]

If I've understand the question correctly, you need first to find circles in your images, you can to using the Hough Circle Transform, here a tutorial in C++

Setting the function with the proper parameters (as I can see, you know the size of the circles, more or less..) you'll obtain the circles center coordinates back from the function:

HoughCircles( src_gray, circles, HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );

circles: A vector that stores sets of 3 values: x_{c}, y_{c}, r for each detected circle.

so using that you'll be able to get the proper ROIs for each one and then apply the function that @ducvd wrote.

If I've understand the question correctly, you need first to find circles in your images, you can to do it using the Hough Circle Transform, here a tutorial in C++

Setting the function with the proper parameters (as I can see, you know the size of the circles, more or less..) you'll obtain the circles center coordinates back from the function:

HoughCircles( src_gray, circles, HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );

circles: A vector that stores sets of 3 values: x_{c}, y_{c}, Xc, Yc, r for each detected circle.

so using that you'll be able to get the proper ROIs for each one circle and then apply the function that @ducvd wrote.

The function give to you also the radius, so what you get at the end is the center of the ROI. Is pretty easy to understand that getting the rectangle coordinate is easy. The top left corner of the rectangle will be (Xc-r-thresh, Yc-r-thresh), while the bottom right corner will be (Xc+r+thres, Yc+r+thresh) where Xc and Yc are the circle center gave back from the function, r is the radius( again given back from the function) and thresh is a parameter that you can set to handle the uncertainty regarding the radius of the circle.

Hope that help

If I've understand the question correctly, you need first to find circles in your images, you can do it using the Hough Circle Transform, here a tutorial in C++

Setting the function with the proper parameters (as I can see, you know the size of the circles, more or less..) you'll obtain the circles center coordinates back from the function:

HoughCircles( src_gray, circles, HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );

circles: A vector that stores sets of 3 values: Xc, Yc, r for each detected circle.

so using that you'll be able to get the proper ROIs for each circle and then apply the function that @ducvd wrote.

The function give to you also the radius, so what you get at the end is the center of the ROI. Is pretty easy to understand that getting the rectangle coordinate is easy. The For each circles (ROI), the top left corner of the rectangle will be (Xc-r-thresh, Yc-r-thresh), while the bottom right corner will be (Xc+r+thres, Yc+r+thresh) where Xc and Yc are the circle center gave back from the function, r is the radius( again given back from the function) and thresh is a parameter that you can set to handle the uncertainty regarding the radius of the circle.

Hope that help