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.2.tar.gz (11.0 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.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modifiedotsu-0.1.2.tar.gz
  • Upload date:
  • Size: 11.0 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.2.tar.gz
Algorithm Hash digest
SHA256 09e7f4f13628d649665a8a15aecf2a2e1f84267634fcfe2861259c62c9e952a2
MD5 d7609b444297a5647fd32eab2d49deaf
BLAKE2b-256 081221504fb486d67373bfc068046e52c2bbfcd70ee89e698c31e4dad1b1c686

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modifiedotsu-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98a61d7a8c8d991f20b3fde93bee711b3d58d51bbeb997ece208d85b8eedbedd
MD5 346178ce8aaea6ae10b1c0f8532caefd
BLAKE2b-256 232478f2f3d1f6e53abd165cbf0fe8a71866b9e3f68ab24985abd27aed0548a1

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