connectedComponents | R Documentation |
connectedComponents
computes the connected components
(i.e. areas of contiguous non-zero pixels) of a binary image.
connectedComponents(
image,
connectivity = 8,
algorithm = "bolelli",
table = TRUE,
stats = TRUE,
target = "new"
)
image |
An an 8-bit (8U) single-channel |
connectivity |
The connectivity neighborhood to decide whether 2 pixels are contiguous. This parameter can take two values:
|
algorithm |
A character string specifying the connected components labeling algorithm to use. This parameter can take six values:
|
table |
A boolean indicating whether the coordinates of the pixels of each component should be returned. |
stats |
A boolean indicating whether the statistics of the connected components should be returned. |
target |
The location where the results should be stored. It can take 2 values:
|
A list with 1 to 4 items:
the number of connected components in the image. It is always returned.
if table=TRUE
, a matrix with 3 columns representing
the identity of the connected components (label), and the x-y coordinates
of the pixels they are composed of.
if stats=TRUE
, a matrix with 8 columns representing
the identity of the connected components (label), the x-y coordinates of
their centroidd, the left and top coordinates of their bounding boxes,
the width and height of their bounding boxes, and their surface areas in
pixels.
if target="new"
a 32S single-channel image in which
each pixel of each connected component is represented by the identity
number of the component, and the background pixels by zero.
Simon Garnier, garnier@njit.edu
Costantino Grana, Daniele Borghesani, and Rita Cucchiara. Optimized Block-Based Connected Components Labeling With Decision Trees. IEEE Transactions on Image Processing, 19(6):1596–1609, 2010.
Kesheng Wu, Ekow Otoo, and Kenji Suzuki. Optimizing two-pass connected-component labeling algorithms. Pattern Analysis and Applications, 12(2):117–135, Jun 2009.
Federico Bolelli, Michele Cancilla, and Costantino Grana. Two More Strategies to Speed Up Connected Components Labeling Algorithms. In Image Analysis and Processing - ICIAP 2017, volume 10485, pages 48–58. Springer, 2017.
Federico Bolelli, Stefano Allegretti, Lorenzo Baraldi, and Costantino Grana. Spaghetti Labeling: Directed Acyclic Graphs for Block-Based Connected Components Labeling. IEEE Transactions on Image Processing, 29(1):1999–2012, 2019.
Federico Bolelli, Stefano Allegretti, and Costantino Grana. One dag to rule them all. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021.
Image
dots <- image(system.file("sample_img/dots.jpg", package = "Rvision"))
dots_gray <- changeColorSpace(dots, "GRAY")
dots_bin <- dots_gray < 200
cc <- connectedComponents(dots_bin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.