Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Binarize 2-D grayscale image or 3-D volume by thresholding

`BW = imbinarize(I)`

`BW = imbinarize(I,method)`

`BW = imbinarize(I,T)`

`BW = imbinarize(I,'adaptive',Name,Value)`

`J = imbinarize(V,___)`

creates a
binary image from image `BW`

= imbinarize(`I`

)`I`

by replacing all values above a globally
determined threshold with `1`

s and setting all other values to
`0`

s. By default, `imbinarize`

uses Otsu's method, which
chooses the threshold value to minimize the intraclass variance of the thresholded black and
white pixels [1]. `imbinarize`

uses a
256-bin image histogram to compute Otsu's threshold. To use a different histogram, see `otsuthresh`

. `BW`

is the output binary image.

`BW = imbinarize(`

creates a binary image from image `I`

,'adaptive',`Name,Value`

)`I`

using name-value pairs to control
aspects of adaptive thresholding.

To produce a binary image from an indexed image, first convert the image to a grayscale intensity image using

`ind2gray`

.To produce a binary image from an RGB image, first convert the image to a grayscale intensity image using

`rgb2gray`

.`imbinarize`

expects floating point images to be normalized in the range`[0,1]`

.

The `'adaptive'`

method binarizes the image using a locally adaptive
threshold. `imbinarize`

computes a threshold for each pixel using the local
mean intensity around the neighborhood of the pixel. This technique is also called Bradley's
method [2]. The `'adaptive'`

method also uses a neighborhood size of approximately 1/8th of the size of the image (computed as
`2*floor(size(I)/16)+1`

). To use a different first order local statistic or a
different neighborhood size, see `adaptthresh`

.

[1] Otsu, N., "A Threshold Selection
Method from Gray-Level Histograms," *IEEE Transactions on Systems, Man, and
Cybernetics*, Vol. 9, No. 1, 1979, pp. 62-66.

[2] Bradley, D., G. Roth, "Adapting
Thresholding Using the Integral Image," *Journal of Graphics Tools*. Vol. 12,
No. 2, 2007, pp.13-21.

Was this topic helpful?