Threshold

Threshold[data]
thresholds data by replacing values close to zero by zero.

Threshold[data,tspec]
thresholds data using threshold specification tspec.

Threshold[image,]
thresholds an image.

Threshold[sound,]
thresholds a sound object.

DetailsDetails

  • Threshold works with 3D as well as 2D images, and also with data arrays of any rank.
  • Threshold[data] is equivalent to Threshold[data,{"Hard",10-10}].
  • The threshold specification tspec can be of the form .
  • Possible tfun names and options include:
  • {"Hard",δ}0 TemplateBox[{x}, Abs]<=delta; x TemplateBox[{x}, Abs]>delta
    {"Soft",δ} 0 TemplateBox[{x}, Abs]<=delta; sgn(x) (TemplateBox[{x}, Abs]-delta) TemplateBox[{x}, Abs]>delta;
    {"Firm",δ,r,p} 0 TemplateBox[{x}, Abs]<=delta-delta p r; (sgn(x) (delta+delta r-delta p  r) (TemplateBox[{x}, Abs]-delta+delta p r))/(delta r) delta-delta p r<TemplateBox[{x}, Abs]<=delta+delta (-p) r+delta r; x TemplateBox[{x}, Abs]>delta+delta (-p) r+delta r;
    {"PiecewiseGarrote",δ}0 TemplateBox[{x}, Abs]<=delta; x-(delta^2)/x TemplateBox[{x}, Abs]>delta
    {"SmoothGarrote",δ,n}
    {"Hyperbola",delta} 0 TemplateBox[{x}, Abs]<=delta; sgn(x) sqrt(x^2-delta^2) TemplateBox[{x}, Abs]>delta;
    {"LargestValues",k}keep the largest k data points
  • In all cases is assumed to be a positive number or a thresholding function tfunc to compute . Each should return a positive number.
  • The parameter conditions for are that is a positive real and a positive real number between 0 and 1.
  • The parameter conditions for is to have be a positive real number.
  • The threshold can be automatically computed using the following methods:
  • {"BlackFraction",b}make a fraction b of all pixels be black
    "Cluster"cluster variance maximization (Otsu's algorithm)
    "Entropy"histogram entropy minimization (Kapur's method)
    "Mean"use the mean level as the threshold
    "Median"use the median pixel level as the threshold
    "MinimumError"KittlerIllingworth minimum error thresholding method

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Zero out elements that are very close to 0:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Perform a clustering threshold on an image:

In[1]:=
Click for copyable input
Out[1]=

Use a threshold function:

In[2]:=
Click for copyable input
Out[2]=

Keep largest data values:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2010
(8.0)
| Updated in 2012
(9.0)