Binarize

Binarize[image]
creates a binary image from image by replacing all values above a globally determined threshold with and others with .

Binarize[image, t]
creates a binary image by replacing all values above t with and others with .

Binarize[image, {t1, t2}]
creates a binary image by replacing all values in the range through with and others with .

Binarize[image, f]
creates a binary image by replacing all channel value lists for which yields True with , and others with .

Details and OptionsDetails and Options

  • Binarize works with any image. It converts multichannel and color images into grayscale images, then produces an image in which every pixel has value or .
  • Binarize[image, {t, t}] effectively sets pixels with value t to , and all other pixels to .
  • Binarize[image, 0] sets all nonzero values to .
  • In Binarize[image, f], the function f is applied to the list of channel values for each pixel.
  • Binarize uses Otsu's cluster variance maximization method. See the reference page for FindThreshold for full documentation of available Method settings.
  • If an explicit threshold value is given, Binarize will ignore the Method option.
  • Binarize also works with Image3D objects.

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Convert a color image to binary:

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

Binarize with an explicit global threshold:

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

Find pixels where the red channel is larger than the green channel:

In[1]:=
Click for copyable input
Out[1]=
New in 7 | Last modified in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »