ScienceEstablished mathematics and its real applications

Explore

Fractal dimension calculator

Measure the fractal dimension of any picture, a leaf, a coastline, lightning or your own drawing, by box counting, or compute the exact dimension of a self-similar shape from the number of copies and their scale.

Similarity dimension

A shape made of N copies of itself, each scaled by the factor r, has the dimension D = log N / log(1/r).

Dimension D: —

Examples:

Box-counting dimension of an image

Choose a sample, upload a black-and-white image (dark pattern on a light background works best) or draw with the mouse or your finger. The calculator covers the picture with grids of boxes from coarse to fine, counts the boxes that contain part of the pattern, and fits a straight line on a log–log plot. Its slope is the dimension.

How box counting works

Cover the picture with a grid of square boxes of side ε and count N(ε), the boxes that contain at least one dark pixel. Halve ε and count again. For a smooth curve N doubles when ε halves; for a filled area it quadruples; for a fractal it grows by a factor between.

If N(ε) behaves like ε−D, then log N = D log(1/ε) + constant, so the points on the log–log plot lie on a straight line of slope D. The calculator uses box sizes from 2 to 256 pixels and fits the line by least squares.

A digital image has a smallest scale (the pixel) and a largest (the picture), so results are estimates. Use large, sharp images, and compare with shapes of known dimension: the samples above give values close to their theoretical dimensions.