Title: Feature Request: General λ-connected (lambda-connected) segmentation
Summary
Both cv2.floodFill() and skimage.segmentation.flood()/flood_fill() implement region-growing using a purely local, pairwise similarity rule — a pixel is added if it differs from an already-included neighbor by less than a fixed tolerance. This is fast and simple, but it inherits a well-known weakness: gradient leakage. A smooth intensity gradient can chain together pixels that are locally similar at every step but globally very different, causing the region to "leak" past intended boundaries.
Proposed addition
Implement λ-connected segmentation, a formal generalization of region-growing based on fuzzy connectedness theory. Instead of a local pairwise test, connectivity between two pixels is defined by the strongest path between them — specifically, the maximum over all paths of the minimum pairwise similarity along that path (a max-min / bottleneck-path formulation). Two pixels are λ-connected if this path strength is ≥ λ.
Why this is a natural fit
• It's a strict generalization: setting λ's degree function to a simple local threshold and ignoring the path constraint collapses back to today's flood_fill() behavior — so it wouldn't replace existing functionality, only extend it.
• It directly addresses flood-fill's most common failure mode (leakage through gradients) without requiring users to switch to a heavier method like GrabCut or a full DL segmentation model.
• Efficient implementation is well understood: this is equivalent to a maximum-capacity/bottleneck shortest-path problem, solvable with a Dijkstra-like or Kruskal-like (max-spanning-forest) approach in effectively linear-ish time for practical image sizes — no need for iterative PDE solvers.
• It would sit naturally alongside existing skimage.segmentation tools (flood, watershed, random_walker, chan_vese) as another region-growing option, giving users a controlled way to compare "naive" vs. "leak-resistant" region growing on the same image.
• Related lambda-connectedness methods already have precedent in imaging toolkits (e.g., Leadtools lambda-connectedness segmentation), so this isn't an unprecedented ask — it would bring scikit-image/OpenCV's region-growing toolbox to parity with a well-established technique in medical/scientific imaging.
python
cv2.segmentation.lambda_connected(image, seed, lam, connectivity=1, degree_func='intensity_diff')
Returns a boolean mask, mirroring flood()'s existing interface for easy comparison in the same script.
References
• L. Chen, Cheng, H.D. and Zhang, J., 1994. Fuzzy subfiber and its application to seismic lithology classification. Information Sciences-Applications, 1(2), pp.77-95.
• L. Chen, "The lambda-connected segmentation and the optimal algorithm for split-and-merge segmentation," Chinese J. Computers, Vol. 14, pp. 321–331, 1991.
Title: Feature Request: General λ-connected (lambda-connected) segmentation
Summary
Both cv2.floodFill() and skimage.segmentation.flood()/flood_fill() implement region-growing using a purely local, pairwise similarity rule — a pixel is added if it differs from an already-included neighbor by less than a fixed tolerance. This is fast and simple, but it inherits a well-known weakness: gradient leakage. A smooth intensity gradient can chain together pixels that are locally similar at every step but globally very different, causing the region to "leak" past intended boundaries.
Proposed addition
Implement λ-connected segmentation, a formal generalization of region-growing based on fuzzy connectedness theory. Instead of a local pairwise test, connectivity between two pixels is defined by the strongest path between them — specifically, the maximum over all paths of the minimum pairwise similarity along that path (a max-min / bottleneck-path formulation). Two pixels are λ-connected if this path strength is ≥ λ.
Why this is a natural fit
python
cv2.segmentation.lambda_connected(image, seed, lam, connectivity=1, degree_func='intensity_diff')
Returns a boolean mask, mirroring flood()'s existing interface for easy comparison in the same script.
References
• L. Chen, Cheng, H.D. and Zhang, J., 1994. Fuzzy subfiber and its application to seismic lithology classification. Information Sciences-Applications, 1(2), pp.77-95.
• L. Chen, "The lambda-connected segmentation and the optimal algorithm for split-and-merge segmentation," Chinese J. Computers, Vol. 14, pp. 321–331, 1991.