fract2D: Calculates the fractal dimension of a 2D image

Description Usage Arguments Details Value Note References See Also Examples

View source: R/fract2D.R

Description

This function calculates the fractal dimension of a black area in a bidimensional image using the method of box-counting.

Usage

1
fract2D(dir = NULL, box.size = NULL, save.dir = NULL, save.name = NULL)

Arguments

dir

Specify a folder containing the image/s to be analysed.

box.size

A vector specifing the box size steps (in pixel) to be used to calculate fractal dimension. By default (NULL) box.size = c(1,2,4,8,16,32,64,128,256,512). Minimun box size cannot be less then 1, corresponding to 1 pixel of the image. Box size steps must be integer.

save.dir

Optional. Set the name of an output folder to save the data as *.rds.

save.name

Optional. Provide a name for the output data.

Details

The fuction calculates the fractal dimension (D) by the method of box-counting. Box-counting method is useful to calculate the fractal dimension of various sets of any dimension and patterns with or withouth self-similarity (Klinkenberg, 1994). The method overlay a series of squares of different size (box.size), with minimun box size that is equal to the resolution of the image. Then, for each box size step the function keep track of the number of squares occupied by the black area into the image. Finally, fractal dimension (D) is estimated by linear regression of log(n°boxes) on log(box.size).

Value

fract2D returns a list containing the following components:

D - A dataframe with the estimated fractal dimension.

raw.dat - A dataframe with the raw data used to calculate the fractal dimension. The data frame contains the name of the image (id), the box size steps (box.size), and the number of boxes for each box size step (box).

Note

The function analyze the fractal dimension of a black area into an image. Then, the images must be converted in black and white before analysis.
Usually, the box sizes should change as a function of a power of two so that they will be evenly spaced in the log space. However, this can result in too few points to fit linear regression. Therefore, according to Dubuc et al. (1989) the function allow to use box.size from 1 to +inf not necessarly with dyadic step.

References

See Also

fract3D to estimate the fractal dimension of a 3D (sliced) image/s.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# The example below calculates the fractal dimension
# of image/s contained in the folder "source.dir".
# Then, a file named "res.rds" is saved into the "output" folder.

fct2D <- fract2D(dir = "source.dir",
                 box.size = c(1,2,4,8,16,32,64,128,256,512),
                 save.dir = "output/",
                 save.name = "res")

fct2D$D # a data frame with the estimated fractal dimension
fct2D$raw.dat # the raw data from which fractal dimension was calculated

## End(Not run)

fractD documentation built on Feb. 5, 2021, 9:06 a.m.