主要内容

Label

在二进制图像中连接的标签组件

  • 库:
  • Computer Vision Toolbox / Morphological Operations

  • Label block

Description

The Label block finds and labels the connected components or objects in a 2-D binary image. The block ignores the background pixels in the input image and searches for connected components within remaining pixels. The block then labels all the pixels of each connected component with a unique number and computes the number of labeled objects.

端口

输入

expand all

输入图像必须是二进制值的向量或矩阵,每个元素代表图像的像素。该块将像素分类为0作为背景像素,搜索像素内的连接组件,值为1.

Data Types:Boolean

Output

expand all

Labeled objects in the input image, returned as a vector or matrix of nonnegative integers. The elements of the output vector or matrix labeled0represent the background, the elements labeled1代表第一个对象,标记的元素2represent the second object, and so on. The size of this output matches the size of theBWinput.

Dependencies

To enable this port, set theOutputparameter to either标签矩阵或者标签矩阵和number of labels.

Data Types:uint8|UINT16|uint32

Number of labeled objects, returned as a scalar.

Dependencies

To enable this port, set theOutputparameter to eitherNumber of labels或者标签矩阵和number of labels.

Data Types:uint8|UINT16|uint32

Parameters

expand all

Specify how the block defines which pixels are connected to each other. If you want to connect adjacent pixels in only the horizontal and vertical directions, select4. If you want to connect adjacent pixels in the horizontal, vertical, and diagonal directions, select8. These figures show how the block defines a connected component for 4-connected and 8-connected pixels. The block considers the white pixels marked by black circles to be connected to each other.

连接类型 Connected Pixels
4-connected pixels

Three-by-three grid, with the middle-left, center, and middle-bottom squares white with black circles in the center. The top-right square is white with no circle, and all other squares are black.

8-connected pixels

Three-by-three grid, with the middle-left, center, middle-bottom, and top-right squares white with black circles in the center. All other squares are black.

将块输出指定为以下选项之一:

  • 标签矩阵- 块在Label港口。

  • Number of labels— The block outputs the number of labeled objects at theCount港口。

  • 标签矩阵和number of labels— The block outputs both the labeled objects and number of labeled objects to theLabelCountports, respectively.

Specify the data type of the outputs at theLabelCountports. When you specify this parameter asAutomatic, the block calculates the maximum number of objects that can fit inside the image based on the image size and the specified connectivity. Using this calculation, it chooses the output data type with the minimum value that guarantees unique region labels.

Use this parameter to specify the behavior of the block when the block finds more objects than the maximum possible value the output data type can represent. The block labels the remaining objects with the value determined by one of these options:

  • 输出数据类型的最大值- 块标记其余对象the maximum value of the output data type.

  • zero- 块标记其余对象0.

Dependencies

要启用此参数,请设置Output data typeparameter to eitheruint8或者UINT16.

块特征

Data Types

Boolean|整数

Multidimensional Signals

Variable-Size Signals

yes

Extended Capabilities

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

版本历史

在R2006a之前引入