Autothreshold
Convert intensity image to binary image
Libraries:
Computer Vision Toolbox /
Conversions
Description
The Autothreshold block converts an intensity image to a binary image using a threshold value. This block uses Otsu's method to determine the threshold.
Examples
Convert Grayscale Image to Binary Image
Convert a grayscale image to a binary image using a global threshold.
Ports
Input
I — Input image
matrix
Input image, specified as an M-by-N matrix.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
| fixed point
Output
BW — Output binary image
matrix
Output binary image, returned as an M-by-N matrix.
Data Types: Boolean
Th — Threshold value
scalar
Threshold value used to convert the intensity image to a binary image, returned as a scalar.
The block calculates the threshold value using Otsu's method. The block computes this value by splitting the histogram of the input image such that the variance of each pixel group is minimized.
Dependencies
To enable this port, select the Output threshold parameter.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
| fixed point
EMetric — Effectiveness metric value
scalar
Effectiveness metric value, returned as a scalar in the range [0, 1].
If all the pixel values of the input image are the same, the value of the
effectiveness metric is 0
. If the image has two unique pixels, or
if the histogram of the image is symmetric, the value of the effectiveness metric is
1
.
Dependencies
To enable this port, select the Output effectiveness metric parameter.
Data Types: single
| double
Parameters
Main
Data Types
Main
Thresholding operator — Specify thresholding operator
>
(default) | <=
Select whether the block includes pixels from the intensity image with values below the threshold or those with values equal to or greater than the threshold in the output binary image.
>
— For pixel values of the input image greater than the threshold, the block outputs1
in the binary image. Otherwise, the block assigns the pixel a value of0
.<=
— For pixel values of the input image less than or equal to the threshold, the block outputs1
. Otherwise, the block assigns the pixel a value of0
.
Output threshold — Output threshold
off
(default) | on
Select Output threshold to return the threshold value the block uses to convert the intensity image to a binary image. Selecting this parameter enables the Th output port.
Output effectiveness metric — Output effectiveness metric
off
(default) | on
Select Output effectiveness metric to return the effectiveness metric value. Selecting this parameter enables the EMetric output port.
Specify data range — Specify input pixel value range
off
(default) | on
Select Specify data range to enable specification of minimum and maximum input pixel values to use to determine the threshold. Selecting this parameter enables the Minimum value of input, Maximum value of input, and When data range is exceeded parameters.
Minimum value of input — Minimum input pixel value
0
(default) | scalar
Specify the minimum value of input pixels to use to determine the threshold.
Maximum value of input — Maximum input pixel value
255
(default) | scalar
Specify the maximum value of input pixels to use to determine the threshold.
When data range is exceeded — Operation to perform when data range is exceeded
Ignore
(default) | Saturate
| Warn and saturate
| Error
Specify the behavior of the block when the value of an input image pixel exceeds the specified data range.
Ignore
— The block ignores all pixels with values outside the specified data range.Saturate
— The block saturates the pixels with values below the data range to the specified minimum value, and those above the data range to the specified maximum value.Warn and saturate
— The block displays a warning message in the MATLAB® command window and saturates the pixel values as specified for theSaturate
option.Error
— The block displays an error message and ends the simulation.
Scale threshold — Specify scale threshold
off
(default) | on
Select Scale threshold to enable specification of a scale factor for the thresholding operation. Selecting this parameter enables the Threshold scaling factor parameter.
Threshold scaling factor — Scale factor for thresholding
1
(default) | scalar
Specify the scaling factor for the thresholding operation as a scalar. The block performs thresholding by multiplying the threshold value computed by Otsu's method by the specified scale factor.
Data Types
For details on fixed-point block parameters, see Specify Fixed-Point Attributes for Blocks (DSP System Toolbox).
Lock data type settings against change by the fixed-point tools — Data type override
off
(default) | on
Select this parameter to prevent the fixed-point tools from overriding the data types you specify in this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).
Block Characteristics
Data Types |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
More About
Fixed-Point Data Types
This diagram shows the data types used in the
Autothreshold block for fixed-point signals. You can use the default
fixed-point parameters if your input has a word length less than or equal to 16.
In this diagram, DT
means data type.
You can set the product, accumulator, quotient, and effectiveness metric data types in the
block mask.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)