Ask Your Question

Revision history [back]

Basically, the idea is to draw the detect circle filled. Therefore, you have a mask. After, just copy your original image into the destination.

// center and radius are the results of HoughCircle
// mask is a CV_8UC1 image with 0
cv::Mat mask = cv::Mat::zeros( img.rows, img.cols, CV_8UC1 );
circle( mask, center, radius, Scalar(255,255,255), -1, 8, 0 ); //-1 means filled
img.copyTo( dst, mask ); // copy values of img to dst if mask is > 0.

You will find the doc here: circle

You could also apply a ROI before copying image to reduce their size:

cv::Mat roi( img, cv::Rect( center.x-radius, center.y-radius, radius*2, radius*2 ) );