How to find a spot inside circle
Hi I am trying to process image1 so that I can find the spot as shown in image2
image1:
image 2:
the code that I am using mergers the spot with the outer circle... is there away to go around this?
int thresh1 = 5;
Mat pyr, timg, gray0(image.size(), CV_8U), gray;
vector< Vec4i > hierarchy;
pyrDown(image, pyr, Size(image.cols/2, image.rows/2));
pyrUp(pyr, timg, image.size());
Mat display_image = image.clone();
int ch[] = {0, 0};
mixChannels(&timg, 1, &gray0, 1, ch, 1);
Canny(gray0, gray, 0, thresh1, 5);
//dilate(gray, gray, Mat(), Point(-1,-1));
gray = gray0 >= (6)*255/11;
//gray = gray0 >= (1)*255/11;
//gray = gray0 >= (1)*255/11;
//gray = gray0 >= (1)*255/11;
imshow( "Hough Circle Transform Demo 2", gray );
waitKey(0);
I don’t understand your question.
Are you looking for defective circles? Are you looking to get the circle(s) that lie within the blue outline? What are you attempting to do with
pyrDown()
,pyrUp()
, andmixChannels()
?I'm glad to see that you're using a high-contrast image to feed to the function calls. Pretty funny how the noisy background in the original image causes false positives. I call those Boltzmann circles, because they emerge from the noise.
It seems that you still need to get every region in the image. Taking my advice, you should find that the image has 16 white regions; one per circle, and one per background.
When you add defects, the number of white regions will decrease, stay the same, or increase, depending on whether or not the defect(s) overlap the circle(s).
Check out:
https://github.com/sjhalayka/obstacle...
... where the input .avi file is at:
https://github.com/sjhalayka/obstacle...
The code finds all regions (sections) in the Canny output, colours them in floating point mode, and then uses their size data to colour each segment.