ImageThin: Extract the skeleton of a black and white image.

Description Usage Arguments Details Value Author(s) References Examples

View source: R/ImageThin.R

Description

Extracts the skeleton of a black and white image (that is, represented by a matrix).

Usage

1

Arguments

matrix

A numeric matrix, representing the black and white image (a pixel of value 0 is from the background).

Details

The skeletonisation algorithm implemented is based on Stentiford (1983). It is a recursive thinning process that allows to extract a curve with a thickness of 1 pixel.

Value

A matrix with values of 1 for the contour and values of 0 for the background.

Author(s)

Alexandre Thiery

References

F.W.M. Stentiford, R.G. Mortimer (1983), "Some new heuristics for thinning binary handprinted characters for OCR." IEEE Transactions on Systems, Man and Cybernetics, 13, pp. 81-84.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
## We use the 'fig-O.png' example image available in this package
file = system.file("extdata", "fig-O.png", package = "ForensicDocument")

## Read the image using 'ImageRead' method, or (similarly with 'png::readPNG')
image1 = ForensicDocument:::ImageRead(file, character_pixel = 0)

## Create the image skeleton
image2 = ForensicDocument:::ImageThin(image1)

par(mfrow = c(1,2))
image(t(image1), xlim = c(0,1), ylim = c(1,0), col = c("white", "black"),
 main = "Original Image", asp = 1)
image(t(image2), xlim = c(0,1), ylim = c(1,0), col = c("white", "black"),
 main = "Skeleton Image", asp = 1)
)

## End(Not run)

ForensicDocument documentation built on May 2, 2019, 5 p.m.