Skip to main content

Threshold

Grayscale image into a binary image by setting a specific threshold value or algorithm.

🖞ïļ Image options and parameters of threshold method

Thresholding is a common image processing technique used to segment an image into regions based on pixel intensity values. The goal of thresholding is to separate objects or features of interest from the background or noise by setting a threshold value that divides the pixel values into two groups: those above the threshold and those below it. Thresholding is widely used for tasks like object detection, image segmentation, and feature extraction.

placeholderplaceholder
Ran in 0.00Ξs (Infinity ops/s)

Kinds of images compatible with algorithm​

Image propertyWhat it meansPossible values
bitDepthnumber of bits per channel[8,16]
componentsnumber of components[1]
alphais alpha channel allowedfalse

Parameters and default values​

With threshold filter there are two ways of passing options: by passing threshold coefficient manually and by calculating threshold with an algorithm.

  • options

Threshold Variant:​

PropertyRequiredDefault value
thresholdno-
outno-

Threshold Algorithm Variant​

PropertyRequiredDefault value
algorithmnootsu
outno-

List of threshold algorithms:​

  • huang
  • intermodes
  • isodata
  • li
  • maxEntropy
  • mean
  • mean
  • minimum
  • minError
  • moments
  • otsu
  • percentile
  • renyiEntropy
  • shanbhag
  • triangle
  • yen
Implementation

Here's how thresholding works:

Choose a threshold value: This value is determined based on the characteristics of the image and the desired segmentation outcome. It can be chosen manually or automatically using various algorithms.

Compare each pixel's intensity value with the threshold value: If the pixel value is greater than or equal to the threshold value, it is assigned to one group (foreground or object). If the pixel value is less than the threshold value, it is assigned to the other group (background).

Generate a binary image: The result of thresholding is a binary image(mask) where pixels belonging to the foreground are assigned a value of 1 (white) and pixels belonging to the background are assigned a value of 0 (black).