Repository for the paper "CS-TRD: a Cross Sections Tree Ring Detection method".
Submitted on 13/05/2023. Last Revision on 21/01/2025. Demo: DEMO.
UruDendro ImageSet: UruDendro. ArXiv paper: ArXiv.
Version 1.0 Last update: 03/12/2024 Authors:
- Henry Marichal, henry.marichal@fing.edu.uy
- Diego Passarella, diego.passarella@cut.edu.uy
- Gregory Randall, randall@fing.edu.uy
All the python source files are in lib/ folder. Dependencies are in externas/ folder. Default configuration files are in config/ folder.
Algorithm 1 is implemented in the file main.py
Canny-Devernay implementation [10] is in externas/devernay_1.0. Python wrapper is in lib/canny_devernay_edge_detector.py
Algorithm 2, 3 and 4 are implemented in the file lib/connect_chains.py
Algorithm 1, 2 and 3 are implemented in the file lib/preprocessing.py
Algorithm 4 and 5 are implemented in the file lib/filter_edges.py
Algorithm 6 is implemented in the file lib/sampling.py
Algorithm 7, 8, 9, 10, 12, 13, 14 are implemented in the file lib/connect_chains.py
Algorithm 11 is implemented in the file lib/basic_properties.py
Algorithm 15, 16, 17 and 18 are implemented in the file lib/postprocessing.py
conda create --name ipol python==3.11
conda activate ipol
conda install -n ipol -c conda-forge geos
conda install -n ipol -c anaconda cmake
conda install -n ipol pip
sudo apt-get update && sudo apt-get install -y libgeos-dev=3.8.0-1build1 cmake=3.16.3-1ubuntu1.20.04.1
python setup.py install
pip install -r requirements.txt
from cross_section_tree_ring_detection.cross_section_tree_ring_detection import TreeRingDetection
from cross_section_tree_ring_detection.io import load_image
args = dict(cy=1264, cx=1204, sigma=3, th_low=5, th_high=20,
height=1500, width=1500, alpha=30, nr=360,
mc=2)
im_in = load_image('input/F02c.png')
res = TreeRingDetection(im_in, **args)
rings_point = res[-1]
python main.py --input input/F02c.png --cy 1264 --cx 1204 --output_dir ./output --root ./
If you want to run the algorithm generating intermediate results you can use the flag --save_imgs
python main.py --input input/F02c.png --cy 1264 --cx 1204 --output_dir ./output --root ./ --save_imgs 1
Detecting pith center automatically can be done using software from IPOL paper "Ant Colony Optimization for Estimating Pith Position on Images of Tree Log Ends" IPOL.
Install repository uruDendro. Then,
from urudendro.remove_salient_object import remove_salient_object
IMAGE_PATH = 'input/F02c.jpg'
OUTPUT_PATH = 'input/F02c_segmented.jpg'
remove_salient_object(IMAGE_PATH, OUTPUT_PATH)
Install repository uruDendro. Then, Tree ring Detection evaluation metrics used by UruDendro. The evaluation code provided here can be used to obtain results on the publicly available UruDendro dataset. It computes multiple metrics described below.
from urudendro.metric_influence_area import main as metric
DETECTION_FILENAME = 'path/to/detection/file'
GROUND_TRUTH_FILENAME = 'path/to/ground/truth/file'
IMAGE_FILENAME = 'path/to/image/file'
CX = 0
CY = 0
THRESHOLD = 0.5
OUTPUT_DIR = 'path/to/output/directory'
P, R, F, RMSE, TP, FP, TN, FN = metric(DETECTION_FILENAME, GROUND_TRUTH_FILENAME, IMAGE_FILENAME, CX, CY, THRESHOLD, OUTPUT_DIR)
where DETECTION_FILENAME is the path to the detection file, GROUND_TRUTH_FILENAME is the path to the ground truth file, IMAGE_FILENAME is the path to the image file, CX is the x pith coordinate in pixels, CY is the y pith coordinate in pixel, THRESHOLD is the threshold to consider a detection as valid (between 0 and 1) and OUTPUT_DIR is the path to the results output directory.
You can run the algorithm in a docker container.
docker pull hmarichal/cstrd:v1.0
In order to run the container you need to mount a volume with the data you want to process (YOUR_DATA_FOLDER). Results will be stored in the mounted volume. Run the following command:
docker run -v YOUR_DATA_FOLDER:/workdir/bin/output -it hmarichal/cstrd:v1.0 /
python main.py --input YOUR_DATA_FOLDER/image_path --cy 1264 --cx 1204 /
--output_dir ./output --root ./ --save_imgs 1
docker build -f .ipol/Dockerfile . -t hmarichal/cstrd:v1.0
@misc{marichal2023cstrd,
title={CS-TRD: a Cross Sections Tree Ring Detection method},
author={Henry Marichal and Diego Passarella and Gregory Randall},
year={2023},
eprint={2305.10809},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
License for th source code: MIT