Questions tagged [watershed]

Watersheds are a term commonly referred to in image processing. Gray level images are considered as topographic water reliefs, where each relief is flooded from its minima. When two lakes merge, a dam is built. The set of all dams that result are what is known as an image's watershed

A grey-level image may be seen as a topographic water relief, where the grey level of a pixel in the image is interpreted as the height within the relief. A drop of water falling on a topographic relief flows along a path to finally reach a local minimum. The watershed of a relief corresponds to the limits of the nearby catchment basins of the drops of water.

In image processing, different types of watershed lines may be computed. There are also many different algorithms to compute watersheds. Watershed algorithm is used in image processing primarily for image segmentation purposes.

Below is a visualization of the MRI of a heart visualized in a topographical way.

http://upload.wikimedia.org/wikipedia/commons/d/db/Relief_of_gradient_of_heart_MRI.png

Source: Wikipedia

These roughly correspond to the edge strength of the image, and the gradient of the image is shown below.

http://upload.wikimedia.org/wikipedia/commons/e/ea/Gradient_of_MRI_heart_image.png

Source: Wikipedia

Watersheds essentially calculate the final edges that are essentially the basins of where the water collects, and an example is shown below.

http://upload.wikimedia.org/wikipedia/commons/0/0d/Watershed_of_gradient_of_MRI_heart_image.png

Source: Wikipedia

Finally, the topographical visualization of the gradient (or the watershed) is shown below. The previous image is inevitably the result that is being sought, but the output of the watershed algorithm is what is shown below.

http://upload.wikimedia.org/wikipedia/commons/0/0f/Relief_view_of_the_watershed_of_the_gradient_of_an_MRI_heart_image.png

Source: Wikipedia


For more information about the different watershed algorithms that exist, check out the following links:

179 questions
78
votes
3 answers

How to define the markers for Watershed in OpenCV?

I'm writing for Android with OpenCV. I'm segmenting an image similar to below using marker-controlled watershed, without the user manually marking the image. I'm planning to use the regional maxima as markers. minMaxLoc() would give me the value,…
Tru
  • 1,467
  • 5
  • 18
  • 27
18
votes
1 answer

Implementing Watershed Segmentation in Java

I'm trying to write my own implementation of Watershed Segmentation for a project. I have a version that returns something resembling the correct segmentation given really trivial pictures. Unfortunately, it's super-slow/inefficient and it may or…
15
votes
2 answers

Shape recognition with numpy/scipy (perhaps watershed)

My goal is to trace drawings that have a lot of separate shapes in them and to split these shapes into individual images. It is black on white. I'm quite new to numpy,opencv&co - but here is my current thought: scan for black pixels black pixel…
bpat
  • 165
  • 1
  • 8
11
votes
1 answer

Find peak (regions) in 2D data

I am looking to find peak regions in 2D data (if you will, grayscale images or 2D landscapes, created through a Hough transform). By peak region I mean a locally maximal peak, yet NOT a single point but a part of the surrounding contributing region…
Honeybear
  • 2,928
  • 2
  • 28
  • 47
10
votes
2 answers

OpenCV Canny + Watershed

I'm using a canny edge detection and a finding contours function (both OpenCV) to create markers for the watershed transform. Everything works fine but I'm not 100% satisfied with the results. The reason is that some edges are missing and therefore…
user667804
  • 740
  • 6
  • 25
9
votes
2 answers

watershed algorithm in matlab

anyone knows how to write a function in matlab to segment the cells and compute the average cell area using the watershed algorithm? any help would be much appreciated. Thank you! Here is an image of yeast cells
Glove
  • 960
  • 6
  • 17
  • 30
9
votes
4 answers

Algorithm for determining the size of air bubbles from image

I'm looking for a good way to isolate an air bubble from the following image. I'm using Visual Studio 2015 and C#. I've heard of the watershed method and believe it may be a good solution. I tried implementing the code solution found here: watershed…
Toster
  • 361
  • 3
  • 17
8
votes
1 answer

(OpenCV) Fast adjacency matrix computation from watershed

I would like to know if there is a faster way, than what I have done below, to compute the region adjacency matrix from a watershed image. Input: watershed image with N regions labeled from 1 to N. Output: adjacency matrix of these N regions. 1. For…
f10w
  • 1,524
  • 4
  • 24
  • 39
7
votes
1 answer

How to use watershed segmentation in opencv python

I have a problem of how to segment the particles individually in this image using watershed segmentation in python .. My main goal is to remove noise by applying filter medianBlur then applying Canny edge detection method . [![img =…
Medo2018
  • 479
  • 1
  • 4
  • 13
6
votes
3 answers

Image segmentation of connected objects with watershed

I'm trying to separate connected objects. It seems that Python and the watershed algorithm (scipy implementation) are well-suited to handle this. Here is my image and automatically generated watershed seed points (local maxima of the thresholded…
ajwood
  • 18,227
  • 15
  • 61
  • 104
5
votes
2 answers

Distance Transform in OpenCV Python automatically converting CV_8UC3 to CV_32SC1 creating an assertion error

I am trying to apply the WaterShed algorithm to an image as per the tutorial: OpenCv WaterShed Docs . I have earlier applied Otsu's thresholding after Gaussian filtering and Morpholigical Transformations on a greyscale image to improve Image quality…
Anindita Bhowmik
  • 844
  • 1
  • 10
  • 18
5
votes
2 answers

Over-segmentation of Watershed algorithm

I followed the 2-D Watershed example in Mathworks.com to separate the connected objects, like the image below: The code is summarize as: bw = imread('some_binary_image.tif'); D = -bwdist(~bw); D(~bw) = -Inf; L = watershed(D); The result…
shapeare
  • 4,133
  • 7
  • 28
  • 39
5
votes
1 answer

Over-watershedding image

I'm having trouble separating cells in microscope images. When I apply a watershed transform I end up cutting up cells into many pieces and not merely separating them at the boundary/minimum. I am using the bpass filter from…
Ben
  • 93
  • 1
  • 7
5
votes
2 answers

Image Segmentation for Color Analysis in OpenCV

I am working on a project that requires me to: Look at images that contain relatively well-defined objects, e.g. and pick out the color of n-most (it's generic, could be 1,2,3, etc...) prominent objects in some space (whether it be RGB, HSV,…
TonyRo
  • 207
  • 1
  • 5
  • 13
5
votes
2 answers

Watershed segmentation algorithm for segmenting occluded leaves in matlab

The main task is to eliminate the complicated background of a leaf and extract the targeted leaf from an occluded leaf image in MATLAB. To eliminate the background i have applied K-means clustering algo. Now the main task is to segment the leaf from…
1
2 3
11 12