Watershed segmentation algorithms cannot work in opencv android. I already used Watershed segmentation algorithms in c++ and java. But in android opencv it gives me error. I don't know why? I know Watershed segmentation algorithms takes 2 parameters of Mat typed object one is 8-bit 3 channel image and other one is 32-bit single channel image. But its gives me wrong parameter error.
Asked
Active
Viewed 1,003 times
2
-
What is the full text of the error? – Mark Miller Jul 13 '15 at 16:23
-
07-14 13:37:53.738: E/AndroidRuntime(1033): CvException [org.opencv.core.CvException: cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/segmentation.cpp:147: error: (-210) Only 8-bit, 3-channel input images are supported in function void cvWatershed(const CvArr*, CvArr*) – Syed Ali hassan Jul 14 '15 at 17:48
-
Watershed algorithms takes two parameters of typed Mat one is 8-bit 3 channel image and other one is 32-bit single channel image. But in error that I mention above comment both images are 8-bit 3-channel. – Syed Ali hassan Jul 14 '15 at 17:51
-
Can you verify the two Mat's you have are of the right type? Use `.depth()` and `.channels()`. – Mark Miller Jul 14 '15 at 19:53
-
Yes, I checked. It display channel 4 of first argument. How I resolve this? – Syed Ali hassan Jul 15 '15 at 04:58
-
My problem was solved. Thanks :). – Syed Ali hassan Jul 15 '15 at 05:17
-
You can post your comment into answer. :) – Syed Ali hassan Jul 15 '15 at 05:18
-
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:13
1 Answers
0
The first step is to double-check each Mat has the type you think it does by using the myMat.depth()
and myMat.channels()
functions. The function watershed
uses two Mat arguments. The first should be an 8-bit, 3-channel image, and the second should be a 32-bit single-channel image.
If they are not the right kind of image, use cvtColor
to convert from what you have to what you need.

Mark Miller
- 706
- 4
- 14
-
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:12