Qu

otsu

Builtin index · Images

result = otsu(x)

Input: x · Output: result

What it is

x is an Image, Vec, or Signal. Compute-and-apply convenience: otsu_threshold followed immediately by threshold in one call.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = otsu(x)
x Image, Vec, or Signalnot documented yet
result Image
Returns the same type/shape threshold(x, level) would (e.g. a new binary Image of the same dimensions for an Image input).

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

m = [10, 20, 30, 220; 15, 25, 200, 230; 120, 130, 210, 225; 125, 135, 205, 215]
img = image_from_matrix(m)

seg = otsu(img)                             # compute Otsu's level and apply it

imshow(seg)

cuts = multi_otsu(img, 3)                   # two cut points -> three bands

banded = multithreshold(img, cuts)
imshow(banded)

k = kapur_threshold(img)                    # entropy-based single threshold

fg = foreground_mask(img, k, radius=1)      # threshold + speck cleanup

print(cuts, k, seg.width, banded.width, fg.width)
output
[30.625, 135.46875] 130.3125 4 4 4
a synthetic field with one bright patch

from images