How to achieve over-segmentation using Watershed Transform from OpenCV?

521 Views Asked by At

I'm trying to over-segment an image by using the marker-based watershed implementation of OpenCV in Java.

My idea was to search for all the local minima and use those as markers. Unfortunately, watershed requires a type CV_8U matrix as the marker input and therefore, I can't really get more than 255 markers.

Does anyone have a workaround for this problem or another solution to achieve over-segmentation using OpenCV?

The original image to the left, the markers in the middle (about 740), resulting segmentation to the right (only 255 regions)

1

There are 1 best solutions below

0
On

The stochastic watershed could help you in this problem. The principle is to apply multiple watersheds.

In your case, you can do:

  1. Find all the local minima
  2. Select N local minima
  3. Apply a watershed
  4. Store the results/boundaries into an accumulator
  5. Repeat steps 2, 3 and 4 M times
  6. Keep the boundaries in the accumulator that have at least X% of M votes.

An other solution would be to use the SMIL library. You can call it from Java, and you are sure that the algorithm implemented is fast and not biased.