Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Find the number of white pixels in contour

I have an image and I'm trying to find the filled circles inside image (MCQ's). I have found all contours and when drawing its drawing the circles but now I don't know how to find the number of white pixels inside contour. Image is in binary pealse suggest something. Thanks

java.util.List<MatOfPoint> contours_crop = new ArrayList<MatOfPoint>();
Imgproc.findContours(crop.clone(), contours_crop, new Mat() ,Imgproc.RETR_EXTERNAL , Imgproc.CHAIN_APPROX_SIMPLE);

//Imgproc.cvtColor(crop, crop, Imgproc.COLOR_GRAY2BGR);
double noPixels = Core.countNonZero(contours_crop.get(3));
Toast.makeText(MainActivity.this, "Pixels:"+noPixels, 10000).show();
click to hide/show revision 2
No.2 Revision

updated 2015-04-20 05:07:42 -0600

berak gravatar image

Find the number of white pixels in contour

I have an image and I'm trying to find the filled circles inside image (MCQ's). (MCQ's).

image description

I have found all contours and when drawing its drawing the circles but now I don't know how to find the number of white pixels inside contour. Image is in binary pealse suggest something. Thanks

java.util.List<MatOfPoint> contours_crop = new ArrayList<MatOfPoint>();
Imgproc.findContours(crop.clone(), contours_crop, new Mat() ,Imgproc.RETR_EXTERNAL , Imgproc.CHAIN_APPROX_SIMPLE);

//Imgproc.cvtColor(crop, crop, Imgproc.COLOR_GRAY2BGR);
double noPixels = Core.countNonZero(contours_crop.get(3));
Toast.makeText(MainActivity.this, "Pixels:"+noPixels, 10000).show();
click to hide/show revision 3
retagged

updated 2015-04-20 05:07:57 -0600

berak gravatar image

Find the number of white pixels in contour

I have an image and I'm trying to find the filled circles inside image (MCQ's).

image description

I have found all contours and when drawing its drawing the circles but now I don't know how to find the number of white pixels inside contour. Image is in binary pealse suggest something. Thanks

java.util.List<MatOfPoint> contours_crop = new ArrayList<MatOfPoint>();
Imgproc.findContours(crop.clone(), contours_crop, new Mat() ,Imgproc.RETR_EXTERNAL , Imgproc.CHAIN_APPROX_SIMPLE);

//Imgproc.cvtColor(crop, crop, Imgproc.COLOR_GRAY2BGR);
double noPixels = Core.countNonZero(contours_crop.get(3));
Toast.makeText(MainActivity.this, "Pixels:"+noPixels, 10000).show();