machinevisiontoolbox.Image.otsu

Image.otsu()

Otsu threshold selection

Returns:

Otsu’s threshold

Return type:

scalar

Compute the optimal threshold for binarizing an image with a bimodal intensity histogram. t is a scalar threshold that maximizes the variance between the classes of pixels below and above the thresold t.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('street.png')
>>> img.otsu()
116
Note:
  • Converts a color image to greyscale.

  • OpenCV implementation gives slightly different result to MATLAB Machine Vision Toolbox.

References:
  • A Threshold Selection Method from Gray-Level Histograms, N. Otsu. IEEE Trans. Systems, Man and Cybernetics Vol SMC-9(1), Jan 1979, pp 62-66.

  • An improved method for image thresholding on the valley-emphasis method. H-F Ng, D. Jargalsaikhan etal. Signal and Info Proc. Assocn. Annual Summit and Conf (APSIPA). 2013. pp1-4

  • Robotics, Vision & Control for Python, Section 12.1.1, P. Corke, Springer 2023.

Seealso:

thresh ithresh adaptive_threshold opencv.threshold