Detect boundaries

Detect boundaries

Detects boundaries of connected objects in images and outputs them as a matrix that contains the coordinates of vertices that form a polygon. The resulting vertices can be used for example in shape detection. In many cases, it is useful to reduce the number of vertices with polyline simplification before further processing.


Input image. This is usually a binary image or a labeled image. To avoid a separate thresholding step one can set the threshold parameter to a non-zero value.
A static threshold for binarizing a gray-level input image. Every pixel in the image whose gray level is higher than threshold is regarded as a part of an object. The default value is zero, which assumes a pre-binarized or labeled input image. Setting this value to a non-zero value may be useful in avoiding a separate thresholding step.
Inverts automatic thresholding result if set to true.
The minimum length of a boundary in world coordinates. If a detected boundary is shorter, it will be discarded. Note that this is a quite rough estimate. The tool calculates the length of a detect boundary quickly based on the number of boundary pixels and camera geometry. It doesn't traverse the boundary and match it to image features to get a really good length estimate.
The maximum length of a boundary in world coordinates. If a detected boundary is longer, it will be discarded. See notes about accuracy above.
The maximum total number of boundary polygons. This parameter together with maxVertices poses an upper limit for the amount of memory the tool may allocate while traversing the boundaries.
The maximum total number of vertices.


The coordinates of the vertices of found boundary polygons. Each polygon is stored as a M-by-2 block (M varies depending on the length of the boundary) in the matrix, and each row stores the (x, y) coordinates of a boundary point in the order the algorithm traversed the boundary. The coordinates are in the world coordinate system.
The number of vertices in each polygon. This matrix has as many rows as there are separate boundaries. Each row has one element: the number of vertices in the polygon.
Boundary mask image. A gray-level image in which the detected edges are marked according to their type. Background is zero, right and bottom edges one, left and top edges two and double edges three.