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:

158 questions
74
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,387
  • 5
  • 16
  • 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…
user978250
  • 165
  • 1
  • 7
10
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,296
  • 1
  • 20
  • 37
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
  • 692
  • 5
  • 23
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
  • 311
  • 3
  • 16
8
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
  • 922
  • 6
  • 17
  • 29
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
  • 15,375
  • 15
  • 54
  • 90
6
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…
Khue
  • 1,224
  • 18
  • 31
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
  • 3,613
  • 6
  • 24
  • 34
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…
5
votes
3 answers

Matlab - Watershed to extract lines - lost information

I have a vein image as follow. I use watershed algorithm to extract the skeleton of the vein. My code: (K is the original image). level = graythresh(K); BW = im2bw(K,level); D = bwdist(~BW); DL = watershed(D); bgm = DL == 0; imshow(bgm); The…
W00f
  • 137
  • 1
  • 8
4
votes
0 answers

Writing robust (size invariant) circle detection (Watershed)

Edit: Quick Summary so far: I use the watershed algorithm but I have probably a problem with threshold. It didn't detect the brighter circles. New: Fast radial symmetry transform approach which didn't quite work eiter (Edit 6). I want to detect…
chris
  • 105
  • 8
1
2 3
10 11