C16 · Objects and correspondences
How to divide an image into regions
Similar, connected and the same object are three different claims. Segmentation starts by deciding which one matters.
Background if needed
Theory
Growth needs admissible neighbors
Region growth starts from a seed. Here a candidate must stay within tolerance of fixed seed intensity and have a four-neighbor path. The processed-queue setting shows real progress; included pixel count can be larger because one processed point discovers several neighbors.
Small tolerance leaves a fragment; large tolerance leaks into background. Comparing against an evolving mean instead of the seed defines a different method. Connected components instead label an existing binary mask. IDs are arbitrary, not confidence values.
Growing from a seed
Select a dark part of the input: the outline marks the seed. Increase tolerance, then select the background and compare the grown region.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Tolerance compares with seed intensity; connectivity requires a neighbor path. A similar distant pixel cannot join without an admissible path.
Parameters and details
Growth compares pixels with fixed seed intensity through four neighbors. k=3 compares intensity, not connectivity: distant regions may share an ID. Label colors do not imply order or confidence.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
A feature cluster need not be connected
K-means alternates nearest-center assignment and center updates. Here intensity is the only feature, there are three centers and fixed initialization. It decreases its squared-distance objective, but other initializations can yield different partitions.
Similarly bright objects can share one cluster. Adding coordinates limits spatial spread; spectral or texture features can distinguish materials. GMM models distributions probabilistically; SLIC forms compact superpixels, not yet semantic objects.
One cluster is not one object
Begin with iteration one: pixels choose their nearest center, then centers become group means. Select a mask pixel and compare its three distances. Add an iteration; unchanged assignments are explicitly marked as convergence.
Exact values are in the point inspector
Grayscale 0…1: black to white.
- Compare three distances: choose the smallest
Exact values are in the point inspector
Color denotes a category, not magnitude.
Inspect the selected point
What the plot shows
The intensity distribution is fixed; markers are centers after the current iteration. Mask color denotes group identity, not center brightness.
- Distribution
- Center 1: 0.2715
- Center 2: 0.3317
- Center 3: 0.7193
Check whether separate objects merged. Without coordinates or other features the method distinguishes only intensity values.
- Changed assignments
- 256
- Convergence iteration (0 = not yet)
- 0
Parameters and details
Each pixel first chooses the nearest old center. Each new center is then its group's mean brightness. Changed assignments: 256. Add an iteration and compare assignments.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Water divides terrain into basins
Watershed treats low scalar values as valleys and high values as barriers. The relief can be gradient magnitude or, for touching objects, negative distance to background. Here an authored terrain has two valleys rather than a photograph: two colored markers explicitly define the basin origins.
For each point, find a path from any marker with the smallest possible maximum elevation. That maximum is the first water level that can reach the point. A nearby low pixel behind a high ridge can therefore fill later than a distant one. The slider shows only points already reached; 0 means still dry, not a drawn boundary between basins.
On a flat plateau, minimum path elevation need not identify a unique winner. Here equal elevations use first-in-first-out queue order: row-major markers; right, down, left, up neighbors, then diagonals with 8-connectivity. Reached labels stay fixed. This policy is not presented as a unique true watershed line.
Open the ridge pass and add a third marker in the same left valley. Accessible paths and basin count change, not the number of real objects. On real data, relief noise, smoothing, gradient strength, background masks and marker choice control leakage and extra regions. Those steps need task-specific choices; this experiment does not automatically preprocess data or detect markers.
Flooding from markers
Raise the water level: valleys fill before the ridge. Open a pass and add a third marker; compare what changes.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Color denotes a category, not magnitude.
Inspect the selected point
What the plot shows
The image line marks this same row. Select a higher or lower point to move the cross-section; compare values at the same column.
- Terrain elevation
- Water level
- Selected column: 8
A label spreads through accessible paths, not toward the geometrically nearest marker. A third marker splits the same valley again. 0 means dry; color identifies a basin, not elevation or confidence.
- Flooded pixels
- 71
- Markers
- 2
Parameters and details
Lighter terrain is higher. Raise the water and watch when it crosses the ridge: the whole path from a marker matters, not just the selected point's height. Label 0 means still dry; a basin's color shows which marker reached it.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Graphs and evolving contours solve different problems
Reference and further methods
The previous experiment used relief, markers and flood order to define a partition. Graph cuts use a different model: label costs at each pixel and costs for cutting neighbor links. Random walker compares probabilities that a random walk on a weighted graph reaches different markers. These methods also require explicit features and weights; recoloring the same basins would not compute either one.
An active contour moves a boundary to reduce energy; Chan–Vese can separate homogeneous regions even without sharp edges. These families are not interchangeable. Evaluate the task: losing a thin channel can matter differently from a small contour shift, even with equal pixel accuracy.
Practice
Test the idea under another condition. Follow the task above the images; point inspection helps explain the result. This exploration is not scored.
Why the region leaked into the background
The seed is inside the left object, but tolerance is too large. Reduce it until the background disappears. Then select inside the right object: the same tolerance now refers to a different seed.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
A similar distant object can be absent because of connectivity, not intensity. Check both intensity difference and path before concluding.
Parameters and details
Growth compares pixels with fixed seed intensity through four neighbors. k=3 compares intensity, not connectivity: distant regions may share an ID. Label colors do not imply order or confidence.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Games
Test your explanation
Question 1 of 5
Same regions but IDs 1 and 2 swapped. Is that wrong?
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Color denotes a category, not magnitude.
Choose one answer. It is checked immediately.
Limitations and references
Limits of this example
Live methods: four-connected fixed-seed growth, intensity k-means and marker-controlled watershed on a 16×16 terrain with explicit FIFO plateau policy and 4/8-connectivity. Watershed does not draw a separate boundary line or find markers automatically. Graphs and active contours are explained, not computed by this growth model.