2

My Question how to count Objects in image on Android Watershed OpenCv?

MTStuart
  • 63
  • 9

1 Answers1

0

Since you didn't tell us which line causes those problem, but i strongly assume you misused erode() and dilate().

You should pass 3rd parameter of each function with valid non-zero Matrix.(e.g. Kernel)

erode & dilate example

// You can change the size of kennel 
// if you want to change the range of erosion & dilation
Mat kelnel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2,2));

Mat fg = new Mat(img.size(),CvType.CV_8U);
Imgproc.erode(threeChannel, fg, kelnel);

Mat bg = new Mat(img.size(),CvType.CV_8U);
Imgproc.dilate(threeChannel, bg, kelnel);
Suhyeon Lee
  • 569
  • 4
  • 18
  • no error sir before i debug it, but when i debug on phone i got error, and in phone appear, unfortunetly, program has stopped. – MTStuart Mar 22 '16 at 18:11
  • I've done solve it, but now my problem is count object in image, somebody can help me ? – MTStuart May 08 '16 at 16:22
  • i'm really in need of help with this question, can you help me, please? https://stackoverflow.com/questions/61216402/how-to-improve-image-segmentation-using-the-watershed – Carlos Diego Apr 28 '20 at 17:11