# Matlab fractal dimension

## Homework Statement

I have a problem trying to code these two programs, one is related to the obtain the fractal dimension of the Koch curve by using the method of the box counting dimension and also using the Grassberger-Procaccia algorithm

## Homework Equations

For the box counting dimension is just the lim N(l)/l as l goes to zero, so first I should generate a meshgrid of the Koch curve and count the number of filled boxes, how I do that in matlab?
For the Grassberger Procaccia or correlation dimension I have reviewed the formula, but no idea how to implement it

## The Attempt at a Solution

I have not really a code to follow here, so any help it would be great

I have submitted an http://www.mathworks.com/matlabcentral/fileexchange/30329-hausdorff-box-counting-fractal-dimension" to compute the fractal dimension Matlab's files exchange.

The function takes as input a binary image I. In this image, nonzero pixels belong to an object (e.g. the kock curve) and 0 pixels constitute the background.

Basically, the algorithm consists in the following steps:

1 - Pad the image with background pixels so that its dimensions are a power of 2.
2 - Set the box size 'e' to the size of the image.
3 - Compute N(e), which corresponds to the number of boxes of size 'e' which contains at least one object pixel.
4 - If e > 1 then e = e / 2 and repeat step 3.
5 - Compute the points log(N(e)) x log(1/e) and use the least squares method to fit a line to the points.
6 - The returned Haussdorf fractal dimension D is the slope of the line.

If you have any questions, you are welcome to ask.

Last edited by a moderator: