Metadata-Version: 2.4
Name: otsu2D
Version: 0.1.1
Summary: Numba-accelerated local 2D Otsu thresholding for 3D images.
Author-email: John Rick Manzanares <jdolormanzanares@impan.pl>
License-Expression: MIT
Project-URL: Homepage, https://github.com/jhnrckmnznrs/otsu2D
Project-URL: Issues, https://github.com/jhnrckmnznrs/otsu2D/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: numba
Requires-Dist: tifffile
Provides-Extra: plot
Requires-Dist: matplotlib; extra == "plot"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# 🧠 Local 2D Otsu Thresholding

**Local 2D Otsu Thresholding** is a **Numba-accelerated** implementation of a *local* 2D Otsu thresholding method for 3D images.

This algorithm adapts the 2D Otsu threshold within a sliding 3D window, enabling robust segmentation in datasets with spatially varying intensity distributions.

---

## ⚙️ Installation

Install the latest stable version from PyPI:

```bash
pip install otsu2D
```

## 🚀 Example Usage

```python
import numpy as np
from otsu2D import getBinary

# Create sample 3D image
img = np.random.randint(0, 256, size=(10, 10, 10), dtype=np.uint8)

# Get threshold map and binary image
binary = getBinary(img, window_size=(3, 3, 3),  mean_window_size =(3,3,3))
```

## 🖥️ Command Line Usage

Run local 2D Otsu thresholding on a single 3D image stack:

    otsu-2d \
      --image path/to/input_stack.tif \
      --window 3 3 3 \
      --mean_window 3 3 3 \
      --outdir outputs \
      --format tif

The output is saved as a binary 3D stack. When using `--format tif`, the result is saved as a single multi-page TIFF file.

## 🗂️ Batch Processing

To process all `.tif` and `.tiff` files inside a directory and its subdirectories:

    otsu-2d-batch \
      --input_dir path/to/input_directory \
      --outdir path/to/output_directory \
      --window 3 3 3 \
      --mean_window 3 3 3 \
      --format tif

The subdirectory structure is preserved in the output directory.

## 📦 Dependencies

- NumPy
- Numba
- tifffile
- Matplotlib, optional, only for visualization with `--show`

Install the required dependencies with:

    pip install otsu2D

To include optional plotting support:

    pip install "otsu2D[plot]"

## 📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

## 🤝 Contributing

Contributions are welcome! If you'd like to fix a bug, add a feature, or improve performance, please open a pull request or contact the maintainers.

## 💬 Contact

For questions, issues, or feedback, open an issue on GitHub.
