Tree Disk Pith Detection
A Python package for analyzing tree rings in cross-sectional images. Originally forked from hmarichal93/apd.
Installation
pip install tree-disk-pith
Usage
Python API
import treediskpith
treediskpith.configure(
input_image="input/tree-disk4.png",
save_results=True,
)
(
img_in,
img_pre,
pith,
) = treediskpith.run()
Command Line Interface (CLI)
Basic usage:
tree-disk-pith --input_image ./input/tree-disk3.png --new_shape 640 --debug
Save intermediate results:
tree-disk-pith --input_image ./input/tree-disk3.png --new_shape 640 --debug --method apd_pcl --save_results
Advanced usage with custom parameters:
tree-disk-pith \
--input_image input/tree-disk3.png \
--cx 1204 \
--cy 1264 \
--output_dir custom_output/ \
--sigma 4.0 \
--th_low 10 \
--th_high 25 \
--save_results \
--debug
CLI Arguments
Argument | Type | Required | Default | Description |
---|
--input_image | str | Yes | - | Input image file path |
--output_dir | str | Yes | - | Output directory path |
--method | str | No | apd | Detection method to use. Choices are apd, apd_pcl, or apd_dl |
--model_path | str | No | - | Path to the weights file (required if using apd_dl method) |
--percent_lo | float | No | 0.7 | percent_lo parameter for the algorithm |
--st_w | int | No | 3 | st_w parameter for the algorithm |
--lo_w | int | No | 3 | lo_w parameter for the algorithm |
--st_sigma | float | No | 1.2 | st_sigma parameter for the algorithm |
--new_shape | int | No | 0 | New shape for resizing the input image. If 0, no resizing is done |
--debug | flag | No | False | Enable debug mode to save intermediate images and outputs |
--save_results | flag | No | False | Save intermediate images, labelme and config file |
Development
Setting up Development Environment
- Clone the repository:
git clone https://github.com/tuke307/tree-disk-pith.git
cd tree-disk-pith
- Create and activate virtual environment:
poetry install
poetry shell
- fetch dataset
python fetch_dataset.py
- Download pretrained model
python fetch_pretrained_model.py