Metadata-Version: 2.3
Name: tree-disk-pith
Version: 0.2.1
Summary: A package for tree disk pith detection in images
License: MIT
Keywords: tree,pith,image processing
Author: Tony
Author-email: tonymeissner70@gmail.com
Requires-Python: >=3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: matplotlib (>=3.9.2,<4.0.0)
Requires-Dist: numpy (>=1.23.0,<2.0.0)
Requires-Dist: opencv-python (>=4.10.0.84,<5.0.0.0)
Requires-Dist: pandas (>=2.2.3,<3.0.0)
Requires-Dist: pillow (>=11.0.0,<12.0.0)
Requires-Dist: scikit-image (>=0.24.0,<0.25.0)
Requires-Dist: scikit-learn (>=1.5.2,<2.0.0)
Requires-Dist: ultralytics (>=8.3.28,<9.0.0)
Project-URL: Homepage, https://github.com/tuke307/tree-disk-analyzer
Project-URL: Repository, https://github.com/tuke307/tree-disk-analyzer
Description-Content-Type: text/markdown

# Tree Disk Pith Detection

[![PyPI - Version](https://img.shields.io/pypi/v/tree-disk-pith)](https://pypi.org/project/tree-disk-pith/)

A Python package for analyzing tree rings in cross-sectional images. Originally forked from [hmarichal93/apd](https://github.com/hmarichal93/apd).

## Installation

```bash
pip install tree-disk-pith
```

## Usage

### Python API

```python
import treediskpith

# Configure the analyzer
treediskpith.configure(
    input_image="input/tree-disk4.png",
    model_path="models/apd_dl.h5",
    save_results=True,
)

# Run the detection
(
    img_in,          # Original input image
    img_pre,         # Preprocessed image
    pith,  # Center of the tree disk
) = treediskpith.run()
```

### Command Line Interface (CLI)

Basic usage:
```bash
tree-disk-pith --input_image ./input/tree-disk4-seg.jpg --model_path ./models/yolo11s-det-pith.pt
```

Advanced usage with custom parameters:
```bash
tree-disk-pith \
    --input_image input/tree-disk3.png \
    --model_path ./models/yolo11s-det-pith.pt \
    --output_dir custom_output/ \
    --new_shape 640 \
    --save_results \
    --debug
```

## CLI Arguments

| Argument | Type | Required | Default | Description |
|----------|------|----------|---------|-------------|
| `--input_image` | str | Yes | - | Input image file path |
| `--output_dir` | str | Yes | ./output | Output directory path |
| `--model_path` | str | No | - | Path to the weights file (required if using apd_dl method) |
| `--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

1. Create and activate virtual environment:
```bash
poetry config virtualenvs.in-project true
poetry env use python
```

```bash
poetry install
eval $(poetry env activate)
```

2. Running tests:
```bash
pytest
```

3. fetch dataset
```bash
python fetch_dataset.py
```

4. Download pretrained model
```bash
python fetch_pretrained_model.py
```

