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
0
votes
0 answers

Watershed algorithm doesn't provide results what I expected | Java | OpenCV

I am trying to locate centers of pits in this image. I used watershed algorithm which I thought is used for finding pits on the image but the result image gives nothing useful for me. Am I used this algorithm properly? Should I do it in another…
Fleczer
  • 63
  • 10
0
votes
0 answers

Best approach to eliminate oversegmentation in Watershed algorithm to enhance edges?

I am trying to implement the Watershed algorithm for image segmentation. I applied in the pre-processing phase Median filter and Morphological Gradient, but the results are way too over segmented as seen in the pictures above. After some research on…
0
votes
0 answers

Using opencv to plot a path in a maze via Pi camera

So I was originally going to use watershed and fumble my way through. I found a maze solver on git that I'm looking to understand better, and make work for a picamera image …
user4339694
0
votes
1 answer

Most efficient way to get consequent IDs in a large matrix

After performing a watershed of a 3D CT, I choose only the particles which are smaller than a certain value and larger than another one. As a final output I however need a matrix only containing consecutive IDs. My implementation is the following: %…
David
  • 513
  • 7
  • 26
0
votes
1 answer

Counting number of cells and nucleus using watershed, skikit image

I am trying to quantify large set of image data. Each image has cells and nucleus. What has to be done is represented in schematic form is as "what I need": An example image is shown in "raw image": I have found an online watershed algorithm …
Sasihci
  • 133
  • 2
  • 12
0
votes
1 answer

Save binary image after watershed

I have problems storing my image after watershed segmentation as a binary image. When I plot the segmentation with cmap=plt.cm.gray it shows a binary image but I don't know how to store the image (without to display it). import cv2 import numpy as…
honeymoon
  • 2,400
  • 5
  • 34
  • 43
0
votes
1 answer

Negative values in Watershed algorithm leading to black image

I'm using the watershed algorithm to try and segment touching nuclei. A typical image may look like: or this: I'm trying to apply the watershed algorithm with this code: show(RGB_img) %Convert to grayscale image I = rgb2gray(RGB_img); %Take…
muZero
  • 948
  • 9
  • 22
0
votes
1 answer

Extracting contours after watershed algorithm

I have a certain image on which I have applied watershed algorithm and obtained satisfactory results. I have used OpenCV and C++ to obtain the result. Now, how do I go about extracting the segmented sections and preferably saving them as contours?
Vin
  • 61
  • 10
0
votes
1 answer

pruning image segments' leftovers

As you see in images below, in some of my segmentation result(segmentation done by watershed transformation method), there are some leftovers left. I want to somehow crop the images so that only the rectangles remain. This operation is only based on…
Sadegh
  • 865
  • 1
  • 23
  • 47
0
votes
0 answers

Using OpenCV watershed algorithm with depth matrix

At the moment I'm working with a ToF camera and I receive a distance image(matrix). I'm able to use Matlab watershed function to find all the valleys in the image. Now I'm trying to use OpenCV watershed function, but it uses a RGB image as input. I…
Matteo B
  • 7
  • 4
0
votes
1 answer

Morphological Watershed From Markers filter on ITK

I'm trying to create a pipeline for image segmentation, with the libraries from ITK. But, when I apply the itkMorphologicalWatershedFromMarkersFilter, the result is a blank image (binary image with only 1's). Does anyone know how to apply this…
0
votes
1 answer

Implement Watershed Segmentation in Objective-C

I am about to make an OS X App for image processing. I need to implement Watershed segmentation algorithm in Objective-c, I've found some opencv c++ code snippets but I am not familiar with c++ so it's hard to make it fully functional. Any help will…
0
votes
2 answers

imwrite in opencv gives a black/white image

I wrote a code for watershed segmentation in C API. Now I am converting all those into C++. so, cvsaveimage becomes imwrite. But when I use imwrite ,all i get is a black image. this is the code:- Mat img8bit; Mat img0; img0 = imread("source.png",…
0
votes
1 answer

How to split labels of watershed segmentation in OpenCV?

I have done a watershed segmentation in OpenCV, but I want to split the segments. I thought about splitting it based on the each segment's RGB value.Since RGB value of different segments will be different. But I can't seem to find out how to do it.…
Abhishek V. Pai
  • 241
  • 1
  • 10
  • 27
0
votes
1 answer

Having too many bounding boxes and circles after watershed algorithm

I am having problems finding bounding boxes and circles after using watershed. I have used Opencv 2 Computer Vision Application Programming Cookbook book for watershed algorithm and opencv.org example for creating bounding boxes and circles. My…
massakrienen
  • 266
  • 2
  • 3
  • 14
1 2 3
11
12