Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

cv.watershed not working like expected #238

Open
matbee opened this issue Mar 29, 2016 · 1 comment
Open

cv.watershed not working like expected #238

matbee opened this issue Mar 29, 2016 · 1 comment
Labels

Comments

@matbee
Copy link

matbee commented Mar 29, 2016

Hey,

I succesfully used the watershed function from Matlab, but OpenCV variant is not working.
I'm not sure if this is mexopencv related, maybe I misunderstood the watershed algorithm in OpenCV.

I'm using following int8 depth image:
image description

because openCV using RGB image format, I replicated these values in a MxNx3-matrix.
As marker I have an int32 matrix where I pointed every local minimum (5 in total),
image description

By using following function

resultOpenCV= cv.watershed(rgbImage,marker);

The segmented matrix looks like this:
image description

In Matlab using following function (even without markers)

resultMatlab= watershed(rgbImage(:,:,1));

This is the correct result:
image description

Where am I wrong?

Thank you

@amroamroamro
Copy link
Collaborator

This is really a question for OpenCV Q&A or Stack Overflow... The mexopencv code for the watershed function is doing very little, other than converting between OpenCV and MATLAB arrays, and calling the C++ function: https://github.com/kyamagu/mexopencv/blob/master/src/%2Bcv/watershed.cpp

Ultimately these two functions are different implementations of the algorithm; MATLAB watershed implements the watershed transform, while OpenCV cv::watershed implements an interactive marker-based watershed segmentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants