Skip to main content

Numba-accelerated local modified Otsu thresholding following Park et al.'s 2D+time formulation, with an optional 3D extension.

Project description

modifiedOtsu

modifiedOtsu implements the local modified Otsu thresholding step used by Park et al. in Segmentation-based tracking of macrophages in 2D+time microscopy movies inside a living animal.

The package default is window_size=(3, 3, 3) for volumetric use. For a 2D+time movie with shape (t, y, x), use window_size=(1, s, s) explicitly for the exact 2D local window used by Park et al. A larger first window dimension, such as (3, 7, 7), is a 3D/temporal extension, not the exact 2D local window from the paper.

The binary decision is:

binary = image > threshold_map

The contrast rejection rule is the relative class-mean rule:

abs(mu_foreground - mu_background) / abs(mu_background) > delta

If mu_background == 0 and the two means differ, the relative separation is considered infinite rather than rejecting the window.

Install

python -m pip install .

For TIFF I/O:

python -m pip install '.[tiff]'

Python API

import tifffile
from modifiedOtsu import getMask

movie = tifffile.imread("movie.tif")  # shape: (t, y, x)
thresholds, mask = getMask(movie, window_size=(1, 7, 7), delta=0.2)

Default volumetric call:

thresholds, mask = getMask(volume, delta=0.2)  # default window_size=(3, 3, 3)

Use delta=0 for ordinary local Otsu without the extra relative-contrast rejection.

For a 3D volume extension:

thresholds, mask = getMask(volume, window_size=(3, 7, 7), delta=0.2)

CLI

One TIFF/NumPy volume:

modified-otsu --input image.tif --window 3 3 3 --delta 0.2

Directory, recursively preserving subdirectories:

modified-otsu \
  --input dataset \
  --output-dir results \
  --recursive \
  --window 3 3 3 \
  --delta 0.2

With threshold maps:

modified-otsu --input image.tif --window 3 3 3 --save-thresholds

Masks are saved as TIFF files with values 0 and 255.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modifiedotsu-0.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modifiedotsu-0.1.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file modifiedotsu-0.1.1.tar.gz.

File metadata

  • Download URL: modifiedotsu-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for modifiedotsu-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4749449858387e611c2ce27f0a4c9027c44f397887bf9dbd6cf2ea2d01ef5fd0
MD5 b96a44c5335a80816515b6acae19386f
BLAKE2b-256 7d8f25578c43c78447fb0f3170817ae123048907422a22de08b462bffc7feacb

See more details on using hashes here.

File details

Details for the file modifiedotsu-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: modifiedotsu-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for modifiedotsu-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c26f9745f37e9b19f17d9f0b65fa16d523c4602bd0e8408e8cd19993c856bca4
MD5 558d57befda99d7164e64da0e1535265
BLAKE2b-256 415bf7616a1517dd94169bf2323919e48cfda11cb00ea5bdc7aeb875401d315a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page