# Binarize

Binarize[image]

creates a binary image from image by replacing all values above a globally determined threshold with 1 and others with 0.

Binarize[image,t]

creates a binary image by replacing all values above t with 1 and others with 0.

Binarize[image,{t1,t2}]

creates a binary image by replacing all values in the range t1 through t2 with 1 and others with 0.

Binarize[image,f]

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

# Details and Options • Binarize works with 2D and 3D images. It converts multichannel and color images into grayscale images, then produces an image in which every pixel has value 0 or 1.
• Binarize[image,{t,t}] effectively sets pixels with value t to 1 and all other pixels to 0.
• Binarize[image,0] sets all nonzero values to 1.
• In Binarize[image,f], the function f is applied to the list of channel values for each pixel.
• Binarize[image] uses Otsu's cluster variance maximization method. Other possible settings for the Method option include:
•  {"BlackFraction",b} make a fraction b of all pixels 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" Kittler–Illingworth minimum error thresholding method
• If an explicit threshold value is given, Binarize ignores the Method option. »

# Background & Context

• Binarize creates a two-level (binary) version of an image whose pixel values correspond to 0s and 1s. Binarize enhances contrast and is typically used for feature detection, image segmentation, or as a preprocessing step prior to application of other image processing functions.
• Binarize is particularly effective when all foreground pixels have higher intensity values than background pixels. It is a pixel (or point) operation, meaning it is applied to each pixel independently.
• Binarize implements intensity thresholding and other binary segmentation methods for images and can operate either automatically or given explicit cutoff values. Applying Binarize removes any alpha channel present and produces an image having a single channel.
• Other more advanced binary segmentation functions include MorphologicalBinarize, RegionBinarize, and ChanVeseBinarize.

# Examples

open all close all

## Basic Examples(1)

Convert a color image to binary:

 In:= Out= ## Possible Issues(1)

Introduced in 2008
(7.0)
|
Updated in 2012
(9.0)