Documentation

vision.Autothresholder System object

Package: vision

Convert intensity image to binary image

Description

Convert intensity images to binary images. Autothresholding uses Otsu's method, which determines the threshold by splitting the histogram of the input image to minimize the variance for each of the pixel groups.

Construction

H = vision.Autothresholder returns a System object, H, that automatically converts an intensity image to a binary image.

H = vision.Autothresholder(Name,Value) returns an autothreshold object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation
Code Generation Support, Usage Notes, and Limitations.

Properties

Operator

Threshold operator on input matrix values

Specify the condition the object places on the input matrix values as one of > | <= . The default is >.

If you set this property to >, and the step method inputs a value greater than the threshold value, the object outputs 1. If the step method inputs a value less than the threshold value, the object outputs 0.

If you set this property to <=, and the step method inputs a value less than or equal to the threshold value, the object outputs 1. If the step method inputs a value greater than the threshold value, the object outputs 0.

ThresholdOutputPort

Enable threshold output

Set this property to true to enable the output of the calculated threshold values.

The default is false.

EffectivenessOutputPort

Enable threshold effectiveness output

Set this property to true to enable the output of the effectiveness of the thresholding. The default is false. This effectiveness metric ranges from 0 to 1. If every pixel has the same value, the object sets effectiveness metric to 0. If the image has two pixel values, or the histogram of the image pixels is symmetric, the object sets the effectiveness metric to 1.

InputRangeSource

Source of input data range

Specify the input data range as one of Auto | Property. The default is Auto. If you set this property to Auto, the object assumes an input range between 0 and 1, inclusive, for floating point data types. For all other data types, the object sets the input range to the full range of the data type. To specify a different input data range, set this property to Property.

InputRange

Input data range

Specify the input data range as a two-element numeric row vector. First element of the input data range vector represents the minimum input value while the second element represents the maximum value. This property applies when you set the InputRangeSource property to Property.

InputRangeViolationAction

Behavior when input values are out of range

Specify the object's behavior when the input values are outside the expected data range as one of Ignore | Saturate. The default is Saturate. This property applies when you set the InputRangeSource property to Property.

ThresholdScaleFactor

Threshold scale factor

Specify the threshold scale factor as a numeric scalar greater than 0. The default is 1. The object multiplies this scalar value with the threshold value computed by Otsu's method. The result becomes the new threshold value. The object does not do threshold scaling. This property is tunable.

 Fixed-Point Properties

Methods

cloneCreate autothresholder object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepConvert input intensity image to binary image

Examples

expand all

Convert an Image to a Binary Image

 img = im2single(rgb2gray(imread('peppers.png')));
 imshow(img);
 hautoth = vision.Autothresholder;
 bin = step(hautoth,img);
 pause(2);
 figure;imshow(bin);

Algorithms

This object implements the algorithm, inputs, and outputs described on the Autothreshold block reference page. The object properties correspond to the block parameters, except:

You can only specify a value of Ignore or Saturate for the InputRangeViolationAction property of the System object. The object does not support the Error and Warn and Saturate options that the corresponding When data range is exceeded block parameter offers.
Was this topic helpful?