Learn R Programming

fractD (version 0.1.0)

fract2D: Calculates the fractal dimension of a 2D image

Description

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

Usage

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.

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

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<U+00B0>boxes) on log(box.size).

References

  • Mandelbrot B.B. (1982) - The fractal Geometry of Nature. San Francisco: W.H. Freman.

  • Klinkenberg B. (1994) - A Review of methods used to determine the fractal dimension of linear features. Mathematical Geology, vol. 26, n<U+00B0> 1. doi: 10.1007/BF02065874

  • Dubuc B., Quiniou J.F., Roques-Carmes C., Tricot C., Zucker S.W. (1989) - Evaluating the fractal dimension of profiles. Physical Review A, vol. 39, n<U+00B0> 3. doi: https://doi.org/10.1103/PhysRevA.39.1500

See Also

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

Examples

Run this code
# 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
# }

Run the code above in your browser using DataLab