Warning: This project is deprecated. TensorFlow Addons has stopped development,
The project will only be providing minimal maintenance releases until May 2024. See the full
announcement here or on
github.
tfa.image.connected_components
Stay organized with collections
Save and categorize content based on your preferences.
Labels the connected components in a batch of images.
@tf.function
tfa.image.connected_components(
images: tfa.types.TensorLike
,
name: Optional[Text] = None
) -> tf.Tensor
A component is a set of pixels in a single input image, which are
all adjacent and all have the same non-zero value. The components
using a squared connectivity of one (all equal entries are joined with
their neighbors above,below, left, and right). Components across all
images have consecutive ids 1 through n.
Components are labeled according to the first pixel of the
component appearing in row-major order (lexicographic order by
image_index_in_batch, row, col).
Zero entries all have an output id of 0.
This op is equivalent with scipy.ndimage.measurements.label
on a 2D array with the default structuring element
(which is the connectivity used here).
Args |
images
|
A 2D (H, W) or 3D (N, H, W) Tensor of image (integer,
floating point and boolean types are supported).
|
name
|
The name of the op.
|
Returns |
Components with the same shape as images .
entries that evaluate to False (e.g. 0/0.0f, False) in images have
value 0, and all other entries map to a component id > 0.
|
Raises |
TypeError
|
if images is not 2D or 3D.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-25 UTC.
[null,null,["Last updated 2023-05-25 UTC."],[],[],null,["# tfa.image.connected_components\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/addons/blob/v0.20.0/tensorflow_addons/image/connected_components.py#L27-L100) |\n\nLabels the connected components in a batch of images. \n\n @tf.function\n tfa.image.connected_components(\n images: ../../tfa/types/TensorLike,\n name: Optional[Text] = None\n ) -\u003e tf.Tensor\n\nA component is a set of pixels in a single input image, which are\nall adjacent and all have the same non-zero value. The components\nusing a squared connectivity of one (all equal entries are joined with\ntheir neighbors above,below, left, and right). Components across all\nimages have consecutive ids 1 through n.\nComponents are labeled according to the first pixel of the\ncomponent appearing in row-major order (lexicographic order by\nimage_index_in_batch, row, col).\nZero entries all have an output id of 0.\nThis op is equivalent with `scipy.ndimage.measurements.label`\non a 2D array with the default structuring element\n(which is the connectivity used here).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|----------------------------------------------------------------------------------------------------------|\n| `images` | A 2D (H, W) or 3D (N, H, W) `Tensor` of image (integer, floating point and boolean types are supported). |\n| `name` | The name of the op. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Components with the same shape as `images`. entries that evaluate to False (e.g. 0/0.0f, False) in `images` have value 0, and all other entries map to a component id \\\u003e 0. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|------------------------------|\n| `TypeError` | if `images` is not 2D or 3D. |\n\n\u003cbr /\u003e"]]