Skip to content

Commit e632eee

Browse files
authored
update doc string to fix broken one and updates some typing errors (#1361)
See for the current broken markdown: https://www.tensorflow.org/addons/api_docs/python/tfa/image/connected_components
1 parent 061b888 commit e632eee

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tensorflow_addons/image/connected_components.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
from tensorflow_addons.utils import types
2020
from tensorflow_addons.utils.resource_loader import LazySO
2121

22-
from typing import Optional
22+
from typing import Optional, Text
2323

2424
_image_so = LazySO("custom_ops/image/_image_ops.so")
2525

2626

2727
@tf.function
2828
def connected_components(
29-
images: types.TensorLike, name: Optional[str] = None
29+
images: types.TensorLike, name: Optional[Text] = None
3030
) -> tf.Tensor:
3131
"""Labels the connected components in a batch of images.
3232
3333
A component is a set of pixels in a single input image, which are
34-
all adjacent and all have the same non-zero value. The components
35-
using a squared connectivity of one (all True entries are joined with
34+
all adjacent and all have the same non-zero value. The components
35+
using a squared connectivity of one (all equal entries are joined with
3636
their neighbors above,below, left, and right). Components across all
3737
images have consecutive ids 1 through n.
3838
Components are labeled according to the first pixel of the
@@ -42,13 +42,17 @@ def connected_components(
4242
This op is equivalent with `scipy.ndimage.measurements.label`
4343
on a 2D array with the default structuring element
4444
(which is the connectivity used here).
45+
4546
Args:
46-
images: A 2D (H, W) or 3D (N, H, W) Tensor of boolean image(s).
47+
images: A 2D (H, W) or 3D (N, H, W) Tensor of image (integer,
48+
floating point and boolean types are supported).
4749
name: The name of the op.
50+
4851
Returns:
4952
Components with the same shape as `images`.
50-
False entries in `images` have value 0, and
51-
all True entries map to a component id > 0.
53+
entries that evaluate to False (e.g. 0/0.0f, False) in `images` have
54+
value 0, and all other entries map to a component id > 0.
55+
5256
Raises:
5357
TypeError: if `images` is not 2D or 3D.
5458
"""

0 commit comments

Comments
 (0)