imbinarize
R2026bBinarize 2-D grayscale image or 3-D volume by thresholding
Syntax
Description
creates a
binary image from 2-D or 3-D grayscale image BW = imbinarize(I)I by replacing all
values above a globally determined threshold with 1 and setting
all other values to 0. The imbinarize
function minimizes the intraclass variance of the thresholded black and white pixels
by using Otsu's method [1].
creates a binary image from image BW = imbinarize(___,Name=Value)I using name-value arguments
to control aspects of the thresholding, in addition to any combination of input
arguments from previous syntaxes.
creates a binary image from image BW = imbinarize(I,threshInit)I based on the initial
threshold threshInit.
Examples
Input Arguments
Name-Value Arguments
Output Arguments
Tips
imbinarizedoes not calculate an effectiveness metric. If you want to know the effectiveness metric for a global threshold, usegraythreshbefore callingimbinarize.By default,
imbinarizecalculates a global threshold by binning the image data into a 256-bin histogram. To specify a different histogram, use theotsuthreshfunction.
Algorithms
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.
References
[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.








