Function rten_imageproc::find_contours

source ·
pub fn find_contours(
    mask: NdTensorView<'_, i32, 2>,
    mode: RetrievalMode
) -> Polygons
Expand description

Find the contours of connected components in the binary image mask.

Returns a collection of the polygons of each component. The algorithm follows the border of each component in counter-clockwise order.

This uses the algorithm from 1 (see Appendix 1), which is also the same algorithm used in OpenCV’s findContours function 2. This function does not currently implement the parts of the algorithm that discover the hierarchical relationships between contours.


  1. Suzuki, Satoshi and Keiichi Abe. “Topological structural analysis of digitized binary images by border following.” Comput. Vis. Graph. Image Process. 30 (1985): 32-46.  

  2. https://docs.opencv.org/4.7.0/d3/dc0/group__imgproc__shape.html#gadf1ad6a0b82947fa1fe3c3d497f260e0