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
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
  • 2
  • 9
4
votes
0 answers

Counting Objects in an image using OPENCV and Python

I'm currently in the pursue of counting the number of shrimps in a given image. I'm using this test image: The code I have used so far is the following: import cv2 import numpy as np from matplotlib import pyplot as plt #Load img path =…
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
  • 155
  • 1
  • 10
4
votes
1 answer

Find Contours after Watershed opencv

I have some troubles with part of my code. I would like to find contours after cv.Watershed algorithm in Python. To be honest, I don't know how to do it. This is my code: kernel = np.ones((3, 3), np.uint8) # sure background area sure_bg =…
Maciej Smyl
  • 41
  • 1
  • 3
4
votes
1 answer

counting cells after watershed segmentation -- openCV/Python

I followed this tutorial given on watershed segmentation to separate the brown cells on the attached image. It went well (cells are separated by blue boundary) but now I would like to count those cells and determine their sizes(pixel number) in…
4
votes
0 answers

connectedComponents error on opencv 2.4.8

I am using Watershed Algorithm for image segmentation (splitting foreground and background) and I get the following error: AttributeError: 'module' object has no attribute 'connectedComponents' The algorithm can be found at:…
S PA
  • 103
  • 8
4
votes
2 answers

Matlab: separate connected components

I was working on my image processing problem with detecting coins. I have some images like this one here: and wanted to separate the falsely connected coins. We already tried the watershed method as stated on the…
dennlinger
  • 9,890
  • 1
  • 42
  • 63
4
votes
1 answer

How to use Kinect depth data in watershed image segmentation

I have both RGB and depth images from Kinect as png format. I'm trying to use depth data with the watershed segmentation but I don't know how to combine both data and obtain a more accurate result. I checked some papers but I didn't understand the…
minyatur
  • 175
  • 2
  • 4
  • 11
4
votes
3 answers

watershed segmentation opencv xcode

I am now learning a code from the opencv codebook (OpenCV 2 Computer Vision Application Programming Cookbook): Chapter 5, Segmenting images using watersheds, page 131. Here is my main code: #include "opencv2/opencv.hpp" #include using…
Yaozhong
  • 89
  • 1
  • 2
  • 7
3
votes
2 answers

Watershed using c# or c++

I am trying to convert the Matlab function watershed into C# or C++. I tried to use this code but CvFindContours returns NULL with this image. I also tried to use this implementation but I had issues with FilterGrayToGray. Does anyone knows how I…
user1042321
  • 45
  • 1
  • 9
3
votes
1 answer

How to watershed two connected circles

There are the two images I am working with: (Here the images are not the same size, but in my programme they are the same) After taking the skimage.metrics.structural_similarity() of the two images above, I have the following thresh: As you can…
SoySoy4444
  • 450
  • 4
  • 11
3
votes
1 answer

skimage watershed segmentation for lung image segmentation

I am getting some kind of noise or unintended output from skimage.segmentation.watershed(). I am new to image processing so I don't know about other parameters of watershed(). After that when I use mark_boundaries() the same output is reflected over…
3
votes
3 answers

Upscale whatershed output to match original image size

Introduction Background: I am segmenting images using the watershed algorithm in MATLAB. For memory and time constraints, I prefer to perform this segmentation on subsampled images, let's say with a resize factor of 0.45. The problem: I can't…
UJIN
  • 1,648
  • 13
  • 28
3
votes
2 answers

MatLab - Segmentation to separate touching objects in an image

I'm using the function regionprops to detect the number of trees on a image taked by drone. First I removed the ground using Blue NDVI: Image with threshold: Then I used the function regionprops to detect the number of trees on image: But there…
3
votes
1 answer

FindContours and CountObject in Binary Image

Somebody can help me to solve it ? I have a binary image which i procced with Watershed Segmentation, My Problem is, how to findContours and CountObject in image ? @Override protected void onActivityResult(int requestCode, int resultCode, Intent…
MTStuart
  • 63
  • 9
1
2
3
11 12