Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imgproc.findContours(cont, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0));
- cleanedMatList = new ArrayList<Mat>();
- int c = 0;
- for (int i = 0; i >= hierarchy.cols(); i++) {
- Rect rect = Imgproc.boundingRect(contours.get(i));
- if (rect.height > HTRESH) {
- Imgproc.rectangle(binary, new Point(rect.x, rect.y), new Point(rect.x + rect.width - 1, rect.y + rect.height - 1), new Scalar(0, 0, 255), 3);
- cleanedMatList.add(c, binary);
- c++;
- }
- }
- List<MatOfInt> digitsHull = new ArrayList<MatOfInt>();
- for(int i=0; i < contours.size(); i++){
- digitsHull.add(new MatOfInt());
- }
- for(int i=0; i < contours.size(); i++){
- Imgproc.convexHull(contours.get(i), digitsHull.get(i));
- }
- List<MatOfPoint> digitRegions = new ArrayList<MatOfPoint>();
- for (int i = 0; i< digitRegions.size(); i++) {
- MatOfPoint dr = digitRegions.get(i);
- dr.push_back(digitsHull.get(i));
- }
- Mat digitsMask = new Mat(srcImage.rows(), srcImage.cols(), CvType.CV_8U);
- Imgproc.drawContours(digitsMask, digitRegions, 0, new Scalar(255, 255, 255), -1);
- Imgproc.morphologyEx(digitsMask, digitsMask, Imgproc.MORPH_DILATE, kernal);
- Mat cleaned = new Mat(srcImage.rows(), srcImage.cols(), CvType.CV_8U);
- diwb.copyTo(cleaned, digitsMask);
- return diwb;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement