ImageTank

# Watershed

This module implements the classical watershed method (ref ImageJ documentation). A structure is as follows:

- You hand in an image and select the channel that should be used for the watershed.
- You need to select the initial seed points for the watershed. If you look at the intensity as a topographical map and the intensity is the height, then this would be the bottom of the valleys.
- You pick if you are viewing this in terms of minima or maxima. For the topographical map you would select a minima.
- You can optionally select a mask to restrict the process.
- You can pick a flowing threshold, or set it to infinity for the minima and -infinity for the maxima. This is essentially another mask mechanism, but based on the intensity of the field.

The algorithm works as follows, explained in terms of minimas:

- Every pixel that has a minima is marked as tentative and given a label based on the point number.
- Find the smallest tentative point in terms of intensity and mark it as accepted.
- For the point that was accepted visit all the neigboring points either the nearest 4 or 8 depending on your selection and mark the points that have not been labeled as tentative and label them using the same label as the point from step 2. Note that here the neighboring point has to lie inside the mask if specified and the intensity value has to be larger than the threshold.
- Go back to step 2 until no tentative points are left.

This resembles a watershed because the point is labeled with the minima point that the water will flow into.

Use the side panel to get a better sense of what the algorithm does and how the thresholds affect the calculations.

What is returned is a table with masks. The order is the same as the seed points, and the seed points are also included in the table.