cc.label: Connected Component Labelling.

Description Usage Arguments Details Value Examples

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

1
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.

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.

Value

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

image

A matrix with labels

summary

A dataframe summarizing the labelled components with 8 following variables.

summary$label

labelling numbers, area: area of each component

summary$aveX, summary$aveY

center position of each component

summary$dX, summary$dY

width and height of each component

summary$edge

If the component is on the edge of the image, this value is 1, otherwise 0.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

Example output



wvtool documentation built on May 1, 2019, 10:27 p.m.

Related to cc.label in wvtool...