Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

I want to count the number of cavities in an image. I have found the countor of the image using findcountour function. Using the countours, is there a way to find the number of cavities in the image.

$
0
0
// Load the library System.loadLibrary("opencv_java249"); // Consider the image for processing Mat image1 = Highgui.imread("C:/Users/omega/workspace/Plankton/src/com/plankton/0.jpg", Imgproc.COLOR_BGR2GRAY); Mat imageHSV = new Mat(image1.size(), Core.DEPTH_MASK_8U); Mat imageBlurr = new Mat(image1.size(), Core.DEPTH_MASK_8U); Mat imageA = new Mat(image1.size(), Core.DEPTH_MASK_ALL); Imgproc.cvtColor(image1, imageHSV, Imgproc.COLOR_BGR2GRAY); Imgproc.GaussianBlur(imageHSV, imageBlurr, new Size(5,5), 0); Imgproc.adaptiveThreshold(imageBlurr, imageA, 255,Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY,7, 5); // Highgui.imwrite("C:/Users/omega/workspace/KaggleExtraction/src/com/hello/0.jpg",imageBlurr); ArrayList contours = new ArrayList(); Imgproc.findContours(imageA, (List) contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE); //Imgproc.drawContours(imageBlurr, contours, 1, new Scalar(0,0,255)); System.out.println("" + contours.size()); for(int i=0; i

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>