Virtual Screen Box Counting 1.6.1


Guido Gonzato, PhD

1. Introduction

This is vsbc, a program to calculate the fractal dimension D of bitmap images using the box counting algorithm.

A preliminary version of this program was described in my paper "A practical implementation of the box counting algorithm", Computers & Geosciences, 24, 1, 95-100, 1998. I realise a better title should have been "A memory-efficient implementation..."

vsbc implements a wide virtual screen (default is 8192x8192, increasable) to load or draw bitmaps on. The wider the screen, the better the accuracy of the calculated D. Since the colour depth of the virtual screen is only 1 bit, the screen uses very little memory.

vsbc should compile under a wide range of operating systems, provided that an ANSI-compliant C compiler is used (gcc and clang are fine); the utility make is also required.

2. Compiling and Installing

This release of vsbc is available as C sources from:

http://vsbc.sourceforge.net/vsbc-1.6.1.tar.gz

Binaries for 32-bit Windows are also available:

http://vsbc.sourceforge.net/vsbc-1.6.1-win32.zip

Read the file src/Makefile and, if needed, change it following the indications contained therein. A very simple program to evaluate the fractal dimension, regr, is also provided, along with runs_test which evaluates the reliability of the resulting linear regression.

To compile the programs, just type:

$ cd src
src$ make

vsbc is known to compile under several flavours of Unix and Windows. Once you get the executables, copy them to a directory included in your path (e.g., /usr/local/bin in UNIX systems).

vsbc uses a default 8192x8192 virtual screen. You can increase or decrease this value by changing the constant NPIXELS in the Makefile.

3. Usage

Using vsbc is very simple. Let's suppose you have a geological map showing the distribution of fault lines in a given area; let's further suppose that these fault lines compose a connected pattern. Scan the map, polish it with your favourite graphic program to eliminate noise, then save it as a PBM file.

PBM is the only graphic format accepted by vsbc. To convert files from other graphic formats (e.g. .jpg, .png, etc.) to PBM, you should use the convert command provided by ImageMagick and/or the GIMP. Please see links at bottom.

Run vsbc as follows:

$ vsbc -v my_map.pbm

The switch -v means `verbose': the program will log its activity. After a while, the program will exit, and the file my_map.dat will have been created. Type the following command to get the regression line out of this data file:

$ regr my_map.dat
-1.446 * x + 3.522
$ _

the absolute value of the first parameter is the calculated fractal dimension D of the fault line distribution. As for the validity of this calculated fractal dimension, you should be aware of the many problems that affect the linear regression technique and the box counting algorithm itself. You can assess the reliability of the results with the command:

$ ./runs_test my_map.dat
Runs Test probability: 0.327

To avoid errors introduced by the position and the size of the image, vsbc zooms it to find an optimal bounding box. That is, if your image is a 1024x1024 picture containing a 100-pixel-long line, vsbc will zoom the image to include only a 100x100 square. You can override this behaviour with the -u switch.

The overall reliability of the box counting algorithm was discussed in Gonzato et al. (2000), "Measuring the fractal dimensions of ideal and actual objects: implications for application in geology and geophysics". Geophys. J. Int, 142, 108-116.

4. Utilities

The subdirectory examples/ contains programs that create a few sample images: a point (D = 0), a line (D = 1), the Koch curve (D = 1.2618), the square Koch curve (D = 1.5), and the Sierpinsky carpet (D = 1.5849).

You can test vsbc on these images using different resolutions. The calculated values are close, but no identical, to the theoretical ones.

These sample programs use functions provided by vscrn.c and vturtle.c. Please have a look at vscrn.h and vturtle.h if you want to write your own software.

Enjoy,

Guido Gonzato, PhD <guido.gonzato at gmail.com>

5. Links

Box counting algorithm:

https://en.wikipedia.org/wiki/Box_counting

My Academia page (papers available here):

https://independent.academia.edu/GuidoGonzato

My ResearchGate page (papers available here):

https://www.researchgate.net/profile/Guido_Gonzato

ImageMagick, free graphics software:

http://www.imagemagick.org/script/index.php

The GIMP, free graphics software:

http://www.gimp.org/



This document was generated using AFT v5.098