# Fractal dimension

Richard Domander edited this page Aug 13, 2018 · 13 revisions

This plugin estimates the fractal dimension of the outline of a binary image by applying a box-counting algorithm. The outline of an image is created by only keeping voxels, which have at least one background neighbour (a neighbourhood in 2D is 8-connected and 3D 26-connected). The operation "hollows" objects so to speak.

In the box-counting algorithm grids of diminishing size are scanned over the image, and the number of boxes containing foreground is counted at each step. As the box size decreases exponentially, and the grid becomes finer, the proportion of foreground boxes increases in a fractal structure. The algorithm also provides an option to move the grid to find one that best fits the image. The best fitting grid covers the objects in the image with the least amount of boxes. See (Wikipedia)[https://en.wikipedia.org/wiki/Box_counting] for further details. Essentially BoneJ Fractal dimension uses a fixed grid scan, where the grid is moved to find optimal covering. The user can decide the starting box size a, smallest box size b, scaling factor m and number of translations t used to find optimal covering. On the first iteration, the box size s equals a. After each step s is divided by m. The algorithm continues until s <= b. At each step the boxes are moved t times.

The box counting algorithm produces a set of (log(n), -log(m)) points, where n = number of boxes with foreground, and m = box size. The points are then passed to a curve-fitting algorithm, which returns the slope of the linear function which describes them (regression fit). The coefficient of the slope is the fractal dimension.

### Fractal dimension

• Menu path: Plugins>BoneJ>Fractal dimension
• Input paremeters
• `ImgPlus<T> inputImage`
• `long startBoxSize`
• `long smallestBoxSize`
• `double scaleFactor`
• `long translations`
• `boolean autoParam`
• `boolean showPoints`
• Output parameters
• `Table<DefaultColumn<String>, String> resultsTable`
• `List<GenericTable> subspaceTables`
• Calls
###### Setup dialog
• Options
• `long startBoxSize`
• Label: Starting box size (px)
• Tool tip: The size of the sampling boxes in the first iteration
• Widget: Spin box, min: 1, step: 1
• Callback to check that `smallestBoxSize <= startBoxSize`
• `long smallestBoxSize`
• Label: Smallest box size (px)
• Tool tip: Sampling box size in pixels where algorithm stops
• Widget: Spin box, min: 1, step: 1
• Callback to check that `smallestBoxSize <= startBoxSize`
• `double scaleFactor`
• Label: Box scaling factor
• Tool tip: The scale down factor of the box size after each step
• Widget: Spin box, min: 1.001, step: 0.01, default: 1.2
• Callback to enforce auto parameters
• `long translations`
• Label: Grid translations
• Tool tip: How many times box grid is moved to find the best fit
• Widget: Slider, min: 0
• Required: false
• `boolean autoParameters`
• Label: Automatic parameters
• Tool tip: Let the computer decide box sizes and scaling
• Callback to set `startBoxSize`, `smallestBoxSize` and `scaleFactor` to automatic values
• If true, box sizes and scale factor are set to predetermined values based on image size.
• `persist: false` - there's no way the enforce automatic values on the saved parameters. This is because parameter initializers happen too early: the saved parameter values are loaded after them. Validaters happen too late: after the dialogue has been closed. Thus we make the user click the checkbox, which activates a callback that sets the parameters to the autovalues in the dialogue.
• Required: false
• `boolean showPoints`
• Label: Show points
• Tool tip: Show (log(size), -log(count)) points
• Required: false
• Other
• `String translationInfo`
• Value: NB: translations affect runtime significantly
• Visibility: MESSAGE (non-interactive)
###### Messages
• If there's no image open
• Show an error dialog
• Abort the run
• If the input image is not binary
• Show an error dialog
• Abort the run
###### Results
• Fractal dimension (Shared table)
• Lists `Fractal dimension` and (`R²`)[https://en.wikipedia.org/wiki/Coefficient_of_determination] measures for each 3D subspace of the input image.
• R² is the coefficient of determination of the line fitted to the (log(n), -log(m)) points
• (log(n), -log(m)) point tables
• Prints (log(foreground), -log(box size)) values for each 3D subspace
###### Differences from BoneJ1
• Option to set box sizes and scaling
• Option to find the best fitting grid (translations)
• Supports any n-dimensional image (hyperspace - e.g. channels and frames - processed as 3D sub-spaces)
• If your image has an inverted LUT, flip it back to normal. Otherwise foreground is interpreted as background!
##### Clone this wiki locally
You can’t perform that action at this time.
Press h to open a hovercard with more details.