1

I have an application using OpenCV and im trying to implement floodfill after using canny edge and use findcontours and boundingrect to get colored letters and segment each words or line of words.

I already implemented it but I dont see the result of floodfill, the result image is only canny edge. I tried to remove canny and use floodfill but i get a lighter color (white-ish) of the image.

here is my code (after canny edge - floodfill part):

    Imgproc.morphologyEx(mask, morByte, Imgproc.MORPH_DILATE, kernel);
    Imgproc.findContours(morByte, contour2, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);
    Imgproc.floodFill(morByte, flooded, flood, new Scalar(255,255,255), new Rect(), lowerDiff, upperDiff, 4);

I tried this (current implemented floodfill line). I also tried to change flooded variable to mask based on this and it's an error/crashes.

I also tried to change my code based from this but I get this error:

CvException [org.opencv.core.CvException: cv::Exception: /build/master_pack-android/opencv/modules/imgproc/src/floodfill.cpp:556: error: (-215) mask.rows == size.height+2 && mask.cols == size.width+2 in function int cv::floodFill(cv::InputOutputArray, cv::InputOutputArray, cv::Point, cv::Scalar, cv::Rect*, cv::Scalar, cv::Scalar, int)
  • Welcome to StackOverflow. It would be helpful if you could reduce your problem into a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve). In it's current form, this is a lot of code for people to work through, which makes it less likely that you will get an answer. – WhoIsJack Jun 25 '18 at 18:34
  • Thank you. I edited my question already. It is still about the floodfill function of OpenCV. – noobprogrmr Jun 25 '18 at 19:14

0 Answers0