Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Matlab fractal dimension

  1. Oct 26, 2011 #1
    1. The problem statement, all variables and given/known data

    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

    2. Relevant 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

    3. The attempt at a solution
    I have not really a code to follow here, so any help it would be great
  2. jcsd
  3. Oct 27, 2011 #2
    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: Apr 26, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook