Turning "how rough is it" into a number somebody else can check
Cited from: Topic 32, Scale Invariance and Fractals
01The Question It Poses
"This coast is more ragged than that one." "This material is more porous." "The vessels on this scan are sparser." You can see all of these at a glance and say almost nothing about what you are seeing. Classical geometry is no help: in the Euclidean scheme any curve has dimension 1 no matter how many turns it takes, and any surface has dimension 2 no matter how many holes it carries. Roughness falls straight through that language.
Box counting asks: can we build a quantity that returns 1 for a smooth curve, 2 for something that fills the plane, and something in between for things in between? And it must be computable from a real photograph or a real map, with no prior knowledge of how the figure was generated. That last condition is the entire reason it beats the self-similarity recipe (magnify by k, get N copies): the recipe needs the generating rule, and in practice all you have is a picture.
02The Rules
Lay the figure over a grid of boxes of side ε.
Count how many boxes the figure touches — touching counts as 1, no matter how much of the box is covered. Call it N(ε).
Shrink ε (halving is common, or dividing by a fixed factor) and return to step 2, building up a series of (ε, N(ε)) pairs.
Plot log(1/ε) on the horizontal axis against log N(ε) on the vertical.
Take the slope of the straight portion of that plot. That is the box-counting dimension D. Formally, D is the limit of log N(ε) ÷ log(1/ε) as ε goes to zero.
The words "straight portion" in step 5 are the heart of the method and the step most often skipped. Real data always bends at both ends of the log-log plot: when boxes approach the size of the whole figure, N flattens out; when they approach the pixel size of the image (or the grain size of the material), you are counting your resolution rather than the shape. Only the middle stretch carries a slope, and a report has to state where that stretch starts and ends.
03What You See When It Runs
Calibrate first on three figures whose answers are known: a straight diagonal (should give 1), a filled square (should give 2), and a Koch curve (exactly log4÷log3 ≈ 1.26).
Halve the box side and the three counts rise by 2×, 4× and 2.3×. Different exponents, different dimensions.
Put all four grid sizes on log-log axes and each of the three gives a straight line with its own slope. That is the whole reason the method is usable.
How high a line sits depends on how big the figure is and says nothing about dimension; only the slope means anything.
Look at the Koch column: the exact answer is 1.26 and the plot measures 1.22. That gap is not a drawing error, it is the method's systematic bias — over a finite figure and a finite range of box sizes, box counting always undershoots slightly. Closing the gap means shrinking the boxes by several more orders of magnitude, which real data rarely allows. So any reported D should be read as "the slope within this scaling window", not as an intrinsic property of the figure.
04What It Explains
Terrain and coastlines. Ranking coasts by D matches what the eye says (South Africa around 1.05, the west coast of Britain around 1.25, the Norwegian fjords around 1.52), and the number tells you directly how much switching rulers will cost you: the larger D is, the more the measured length jumps when you change map resolution.
Porous materials and interfaces. The pore structure of catalyst supports, activated carbon and battery electrodes has a box-counting dimension that tracks specific surface area. What engineering usually cares about is not D itself but the change in D — how far apart two process routes put the same material is how much more crumpled one of them made the interface.
Morphological measures in medical imaging. Retinal vessel networks, trabecular bone, tumour margins and bronchial trees have all been quantified this way. The value is that it converts "looks sparser, looks more irregular" into a continuous variable that can enter a statistical model, instead of a reader's subjective score.
The geometry of critical systems. The cluster that has just spanned a percolation lattice has a fractal dimension known exactly in two dimensions: 91/48 ≈ 1.90 → ref · Percolation. Results like that double as calibration objects: if your code cannot recover 1.90 on a simulated percolation cluster, the problem is your code, not your data.
What It Cannot Explain
It supplies no mechanism. D is a descriptive number. It tells you how fast detail accumulates with resolution; it does not tell you how the shape came about. A branching supply network, a critical system and a scale-free erosion process can all return the same D while making entirely different testable predictions. Using D as an explanation mistakes a measurement for a theory.
It is not a fingerprint. Two unrelated figures can share a dimension. That limitation was walked into during the fractal authentication of Pollock's drip paintings: in 2006 Jones-Smith and Mathur showed in Nature that casual sketches of stars and scribbles pass the same fractal test. D is fit for comparison, not for identification.
It is acutely sensitive to the scaling window. The Koch curve on this page measuring 1.22 rather than 1.26 across four box sizes is what that bias looks like. Real data often offers a usable window barely an order of magnitude wide, and over a stretch that short a straight line and a gently bending one are indistinguishable.
It is sensitive to preprocessing. The binarisation threshold, denoising, image resolution, even where the grid origin sits will all move the measured D. Comparing D across studies requires standardising the entire pipeline first, or you are comparing pipelines rather than shapes.
It is not the only "dimension". Hausdorff dimension, information dimension and correlation dimension each have their own definition. They coincide on well-behaved mathematical objects and need not coincide on real ones. Box counting is the easiest to compute, not the most authoritative.
It gives wrong answers on self-affine objects. If an object scales differently along its two axes — the classic case being a time series plotted as a curve, where the horizontal axis is time and the vertical is price, quantities of entirely different kinds — then the result depends on the aspect ratio you happened to choose, and the number means nothing. Such objects need other tools (detrended fluctuation analysis and its relatives); do not force box counting onto them.