Skip to content

A space colonization algorithm algorithm to create tree- and root-like structures in 3D. The implementation combines with the Bresenhams line algorithm in order to return a binary 3D matrix which, for instance, can be used as input for CFD simulations using LBM.

License

Notifications You must be signed in to change notification settings

tresnjo/binary-root-generation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Binary root generation

The project combines the well-known space colonization algorithm with Bresenhams line algorithm extended to consider thicknesses of lines in order to produce realistic roots and trees. For the ones that wants to understand the algorithms in detail, I heavily recommend this fantastic article Space Colonization Algorithm by 'ciphrd' and this wikipedia article Bresenham's Line Algorithm.

The roots/trees are generated over a binary 3D grid. The intent of this project is to supply researchers with a tool to generate binary voxel representations of roots/trees. These representation can be used as inputs for simulations in computational fluid dynamics and specifically those performed using the lattice Boltzmann method (LBM).

Table of contents

Installation

In order to run the code, the user will need to supply themselves with the following packages:

  • numpy, scipy, matplotlib, h5py, os, skan

Usage and tips

First configure the parameters in config.py. In the config.py file, one specifies settings such as the root thickness, the number of points sampled in the space colonization algorithm, the domain size in pixels, and much more. There's great variability that can be extracted from this code, so I suggest the user plays around with the parameters themselves. See Examples to study some of the possible geometries that have been generated.

The utils.py come with three defined crown types, these are: ellipsoidal, cylindrical and cuboid. The crown types are used for sampling points that are later used in the space colonization algorithm. By choosing different crown types, one can tailor the shape of the root/tree. The user can of course implement new crown types if they are interested.

The user can also specify whether they want save it as an H5 which has becoming increasingly popular in recent times. For larger domain sizes that are strenuous to visualize using matplotlib's voxel plot, I suggest the user to install VisIt, see VisIt Installation Guide.

The second and final step just involves running the main simulation scipt main.py. If wished, one might output the configuration txt file which saves the information from the config.py so that one can recreate the exact root/tree in the future. It also contains information such as the number of surface and volume voxels, and surface-to-volume ratio, and other parameters that might be of interest.

Examples

This chapter shows some examples of roots that have been generated using the provided code. The examples together with the configuration files for the settings can be found under the directory examples. Note that these configuration files are quite old so they might be missing new features that have been added to the configuration file.

Image 1

A bush like structure.

Image 1

A fibrous root system reminiscent of grass roots.

Image 1

A taproot structure with thick branches.

Image 1

A taproot structure with high gravity forcing of branches.

About

A space colonization algorithm algorithm to create tree- and root-like structures in 3D. The implementation combines with the Bresenhams line algorithm in order to return a binary 3D matrix which, for instance, can be used as input for CFD simulations using LBM.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages