Back to top

me | blogs | notes | tags | categories | feed | home |

image thresholding



tags: no_tags
categories: uncategorized


Can be used for image segmentation

multi-otsu thresholding

  • The multi-Otsu threshold is a thresholding algorithm that is used to separate the pixels of an input image into several different classes, each one obtained according to the intensity of the gray levels within the image
  • Multi-Otsu calculates several thresholds based on the number supplied by the user.
  • for multi classes
import numpy as np
import matplotlib.pyplot as plt
from skimage import io, img_as_ubyte
from skimage.filters import threshold_multiotsu

image = io.imread(img_path)

thresholds = threshold_multiotsu(image, classes=n) # default 3

regions = np.digitize(image, bins=thresholds)
# https://numpy.org/doc/stable/reference/generated/numpy.digitize.html
output = img_as_ubyte(regions)

plt.imshow(output)