Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

I can't seem to attach images to this answer, so I put the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpg

My Hough function call looks like:

include <opencv2 opencv.hpp="">

using namespace cv;

pragma comment(lib, "opencv_world331.lib")

include <iostream>

include <cmath>

using namespace std;

int main(void) { Mat frame = imread("circles.jpg");

cvtColor(frame, frame, CV_BGR2GRAY);

// Find the two circles.
vector<Vec3f> circles;

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

cvtColor(frame, frame, CV_GRAY2BGR);

for (size_t i = 0; i < circles.size(); i++)
{
    Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
    int radius = cvRound(circles[i][2]);
    circle(frame, center, 3, Scalar(0, 255, 0), -1, 8, 0);
    circle(frame, center, radius, Scalar(0, 0, 255), 3, 8, 0);
}

imshow("Hough Circles", frame);

waitKey(0);
return 0;

}

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

I can't seem to attach images to this answer, so I put the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpg

My Hough function call looks like:

include <opencv2 opencv.hpp="">

using namespace cv;

pragma comment(lib, "opencv_world331.lib")

include <iostream>

include <cmath>

using namespace std;

int main(void) { Mat frame = imread("circles.jpg");

cvtColor(frame, frame, CV_BGR2GRAY);

// Find the two circles.
vector<Vec3f> circles;

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

cvtColor(frame, frame, CV_GRAY2BGR);

for (size_t i = 0; i < circles.size(); i++)
{
    Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
    int radius = cvRound(circles[i][2]);
    circle(frame, center, 3, Scalar(0, 255, 0), -1, 8, 0);
    circle(frame, center, radius, Scalar(0, 0, 255), 3, 8, 0);
}

imshow("Hough Circles", frame);

waitKey(0);
return 0;

}

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

I can't seem to attach images to this answer, so I put the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpg

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all of the circles (including one elliptical defect that was identified as a circle).

I can't seem to attach images to this answer, so I put the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpg

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (including (plus one elliptical defect that was identified as a 16th circle).

I can't seem to attach images to this answer, so I put the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpg

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle).

I can't seem to attach images to this answer, so I put Here is the altered image on GitHub: https://github.com/sjhalayka/random_images/blob/master/circles.jpgthat I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle).

Here is the altered image that I am describing:

image description

Here is the output, with the circles in red:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle).

Here is the altered image that I am describing:

image description

Here is the output, with the circles in red:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle).

Here is the altered image that I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle).circle). In other words, it works perfectly.

Here is the altered image that I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.

Here is the altered image that I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

The results are shown, where circles are in red, and have green centres:

image description

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.

Here is the altered image that I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

The results are shown, where circles are in red, and have green centres:

image description

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.

Here is the altered image that I am describing:

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.

Here is the altered image that I am describing:describing (hurts the eyes, doesn't it?):

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.

Here Below is the altered image that I am describing (hurts describing. It hurts the eyes, doesn't it?):it?

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly.perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it?

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it?it? Well it's eye candy to the Hough circle transformation.

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quinncunxial eye candy to the Hough circle transformation.

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quinncunxial quincunxesque eye candy to the Hough circle transformation.

image description

My Hough circle transform function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quincunxesque eye candy to the Hough circle transformation.

image description

My Hough circle transform transformation function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quincunxesque eye candy to the Hough circle transformation.

image description

My Hough circle transformation function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

You know how big the radii of the 15 circles are. Take the mean radius. Any white region much smaller or larger than this mean radius is likely a defect.

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quincunxesque eye candy to the Hough circle transformation.

image description

My Hough circle transformation function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

You know how big the radii of the 15 circles are. Take the mean radius. Any white region with a radius much smaller or larger than this mean radius is likely a defect.

@AdhilIqbal -- You need to alter your image before you can run the Hough circle transformation on it -- do a Canny() edge detection on it, and then fill in (floodFill()) all but the largest region to get a black and white (binary) image. That stops false positives (circles that appear out of the noise) from occurring, as well as finds all 15 of the circles (plus one elliptical defect that was identified as a 16th circle). In other words, it works perfectly, and it's about as simple as it gets.

Below is the altered image that I am describing. It hurts the eyes, doesn't it? Well it's quincunxesque eye candy to the Hough circle transformation.transformation. You really need to think like the computer.

image description

My Hough circle transformation function call looks like:

// Parameter values are very much obtained by trial and error
HoughCircles(frame, // input
    circles, // output
    CV_HOUGH_GRADIENT, // method
    1, // dp
    5, // minimum distance
    5, // param1
    5, // param2
    0, // minimum radius
    25); // maximum radius

You know how big the radii of the 15 circles are. Take the mean radius. Any white region with a radius much smaller or larger than this mean radius is likely a defect.