Learn R Programming

wvtool (version 1.0)

cc.label: Connected Component Labelling.

Description

A function labels the connected components in a binary image. For example, it can be used for statistical analysis of tracheids (see examples).

Usage

cc.label(x, connect=8, inv=FALSE, img.show=FALSE,text.size=0.3)

Arguments

x
A binary image (A matrix with 0 and 1)
connect
8-connectivity or 4-connectivity. Default is 8-connectivity.
inv
inverse the binary image x before labelling. Labelling the connected area with 0 when this is TRUE.
img.show
If this is TRUE, the image with labelling numbers are shown.
text.size
the size of labelling numbers used when img.show=TRUE.

Value

a list with 2 components (a matrix and a dataframe)

Details

Labelling the connected components with pixels equal to 1 (white) in a binary image (If pixels equal to 0 (black) should be labelled, select inv=TRUE). The function returns the labelled image and the statistical data of the labelled components.

Examples

Run this code
## Not run: 
# data(cryptomeria)
# img <- rgb2gray(cryptomeria)
# img.c <- crop(img,300,300)
# img.bin <- gray2bin(img.c, auto=FALSE, th=180)
# par(mfrow=c(2,2))
# test <- cc.label(img.bin, connect=8, img.show=TRUE)
# hist(test$summary$area,main="histogram of area")
# hist(test$summary$dX,main="histogram of dX")
# hist(test$summary$dY,main="histogram of dY")
# ## End(Not run)

Run the code above in your browser using DataLab