Main Content

Trace Boundary

Trace object boundaries in binary images

  • Library:
  • Computer Vision Toolbox / Analysis & Enhancement

  • Trace Boundary block

Description

The Trace Boundary block traces object boundaries in binary images, where nonzero pixels represent objects and zero valued pixels represent the background.

Ports

Input

expand all

Input binary image, specified as an M-by-N matrix.

Data Types: Boolean

Coordinate of the boundary starting point, specified as a two-element vector in the form [X Y].

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Output

expand all

Coordinates of the boundary points, returned as an M-by-2 matrix where each row represents a coordinate of a boundary pixel in the form [X Y]. M is the number of traced boundary pixels in the output image. Value of M must be less than or equal to the value specified by Maximum number of boundary pixels parameter.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Parameters

expand all

Select these options to specify how the block defines which pixels are connected to each other.

  • 8 — Connect adjacent pixels in the horizontal, vertical, and diagonal directions.

  • 4 — Connect adjacent pixels in only the horizontal and vertical directions.

For more information, see Connectivity.

Specify the type of initial search direction to find the boundary pixel connected to the starting pixel specified at Start Pt input port. These options are dependent on the specified Connectivity parameter.

For Connectivity parameter set as 4, the block enables North, East, South, and West search directions. This figure illustrates the four possible initial search directions with respect to the starting pixel.

Search direction with Connectivity set to 4

For Connectivity parameter set as 8, the block enables additional Northeast, Southeast, Southwest, and Northwest search directions. This figure illustrates the eight possible initial search directions with respect to the starting pixel.

Search direction with Connectivity set to 8

Select the direction to trace the boundary as Clockwise or Counterclockwise.

Specify the maximum number of boundary pixels for the starting point as a scalar. The number of rows at Pts output port must be less than or equal to this value.

Block Characteristics

Data Types

Boolean

Multidimensional Signals

no

Variable-Size Signals

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2011b

See Also

Blocks

Functions