How to find a spot inside circle

asked 2017-11-26 06:36:48 -0600

AdhilIqbal gravatar image

Hi I am trying to process image1 so that I can find the spot as shown in image2

image1:

image description

image 2:

image description

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);

image description

edit retag flag offensive close merge delete

Comments

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(), and mixChannels()?

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).

sjhalayka gravatar imagesjhalayka ( 2017-11-26 11:59:01 -0600 )edit

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.

sjhalayka gravatar imagesjhalayka ( 2017-11-27 10:23:44 -0600 )edit