Hi all,
I apologize for the very basic question, but I'm stuck with this because I've found tons of people with different solutions. So I'm trying to figure out what's the best solution.
Given this black image, with some pixels white like this:
how can get the coordinate of the green pixel that I personally marked?
So the steps would be:
- How can I find the largest (in order to exclude noise) white blob in a black image?
- How can I compute its center?
Until now I achieved this with findCountours
that modify this image and then moments
:
// Useless
ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
// findcontours modify the imageMat
Imgproc.findContours(imageMat, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
// then I do this
Moments moment = Imgproc.moments(cvMat, true);
int x = (int) (moment.get_m10() / moment.get_m00());
int y = (int) (moment.get_m01() / moment.get_m00());
Yes I'm working with Android. Some guys told me that computing moment it's overkill in this situation can anyone tell me something more?