🧠 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:
pip install otsu2D
🚀 Example Usage
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.
Metadata
Release files for otsu2D 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| otsu2d-0.1.1.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| otsu2d-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.8 kB
Release files / otsu2d-0.1.1.tar.gz
| Download URL | otsu2d-0.1.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7f81cc22d0c35cded883dac0208f3ad0a52216acc7d09d81dd25f9a447ed5d8
|
|
BLAKE2b-256 checksum How to use checksums |
c945b447671c8e458b0566728632d85fbe54906d368116ddd42342c924a6ff3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / otsu2d-0.1.1-py3-none-any.whl
| Download URL | otsu2d-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d168e1c5f99ba27a9e414c2b26f48e3bd10f20669507e8499e44ad769c3eff0
|
|
BLAKE2b-256 checksum How to use checksums |
c77f468079ee0c69cc6e983b3a77443b8d21c4e5a90646f6998269b62dc7e25b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|