{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / filters / rank / generic / otsu

function

skimage.filters.rank.generic:otsu

source: /dev/scikit-image/src/skimage/filters/rank/generic.py :1555

Signature

def   otsu ( image footprint out = None mask = None shift_x = 0 shift_y = 0 shift_z = 0 )

Summary

Local Otsu's threshold value for each pixel.

Parameters

image : ndarray of shape ([P,] M, N) and dtype (uint8 or uint16)

Input image.

footprint : ndarray

The neighborhood expressed as an ndarray of 1's and 0's.

out : ndarray of shape ([P,] M, N), same dtype as input `image`

If None, a new array is allocated.

mask : ndarray of dtype (int or float), optional

Mask array that defines (>0) area of the image included in the local neighborhood. If None, the complete image is used (default).

shift_x, shift_y, shift_z : int

Offset added to the footprint center point. Shift is bounded to the footprint sizes (center must be inside the given footprint).

Returns

out : ndarray of shape ([P,] M, N), same dtype as input `image`

Output image.

Examples

from skimage import data
from skimage.filters.rank import otsu
from skimage.morphology import disk, ball
import numpy as np
img = data.camera()
rng = np.random.default_rng()
volume = rng.integers(0, 255, size=(10,10,10), dtype=np.uint8)
local_otsu = otsu(img, disk(5))
thresh_image = img >= local_otsu
local_otsu_vol = otsu(volume, ball(5))
thresh_image_vol = volume >= local_otsu_vol

Aliases

  • skimage.filters.rank.otsu