This is an (incomplete) port of the LeafGen MATLAB package to GNU Octave.
The purpose is to simplify deployment of LeafGen as part of the virtual forest radiative transfer package.
The port also adds:
- cli entrypoint that takes config as JSON
- docker image
./qsm_direct_cli.m qsm_direct_config.example.json
See the example config file for details on the parameters.
docker run --rm -ti ghcr.io/qforestlab/leafgen:latest bash
The image is published to GitHub Container Registry on pushes to main and for version tags (v*). Each push publishes a latest tag; version-tag pushes also publish the matching version tag.
Mainly minor syntax changes to make the code compatible with Octave. The main differences are:
- double quotes to single quotes
- use
strcmpinstead of==for string comparison - don't use
+for string contatenation.
- All visualization related functionality is missing, as it is beyond the scope of this port.
- Testing non qsm-direct method approaches.
LeafGen is a MATLAB package containing methods for generating virtual foliage on 3D tree models based on parametric leaf distributions. The tree models can be either quantitative structure models (QSM) or point clouds of trees. The user can choose parametric distribution functions on variables of tree structure for the leaf area density distribution (LADD), leaf orientation distribution (LOD), and leaf size distribution (LSD).
The general LeafGen framework is presented in the following article
- Mönkkönen P, Van den Broeck W, Ali-Löytty S, Calders K, and Raumonen P (2025). LeafGen: Foliage Generation in 3D Tree Models. Methods in Ecology and Evolution. https://doi.org/10.1111/2041-210X.70080.
For technical details and guidance on usage, see the LeafGen documentation.
To quickly test running the method:
- Download or copy the LeafGen repository to your computer.
- Open MATLAB and set the main path to the
srcdirectory of the LeafGen repository - Open and run one of the three main files in MATLAB (preferably start with either
main_qsm_direct.mormain_canopy_hull.m, as themain_leaf_cylinder_library.mrequires a long computation.)
To view a detailed tutorial on each of these files and more, see the LeafGen documentation.
The code in this repository is licensed under GPLv3. See LICENSE for more infromation.
The files in src/example-data/ include material derived from:
Dataset: Calders, K., Verbeeck, H., Burt, A., Origo, N., Nightingale, J., Malhi, Y., Wilkes, P., Raumonen, P., Bunce, R., & Disney, M. (2022). Terrestrial laser scanning data Wytham Woods: individual trees and quantitative structure models (QSMs) (Version 1.0) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.7307956
Related article: Calders, K., Verbeeck, V., Burt, A., et al. Laser scanning reveals potential underestimation of biomass carbon in temperate forest. Ecological Solutions and Evidence. https://doi.org/10.1002/2688-8319.12197
License: Creative Commons Attribution 4.0 International (CC BY 4.0). https://creativecommons.org/licenses/by/4.0/
These files remain licensed under CC BY 4.0.

