thresholdcv

Applies a threshold to each element of the given image, handle, resulting in a grayscale image, R, whose pixels represent the elements exceeding the threshold.

Syntax

[computedthreshold, R] = thresholdcv(handle, threshold, max, type)

Inputs

handle
Handle of an image.
Type: integer
threshold
Real vector of [width height] representing the dimensions of R.
Type: vector
fx
Threshold value.
Type: scalar
max
Maximum value to use with type value of 8 or 16.
Type: scalar
type
Threshold type. Valid values are:
0
R(x,y) = max if handle(x,y) > threshold and 0 otherwise.
1
R(x,y) = 0 if handle(x,y) > threshold and max otherwise.
2
R(x,y) = threshold if handle(x,y) > threshold and handle(x,y) otherwise.
3
R(x,y) = handle(x,y) if handle(x,y) > threshold and 0 otherwise.
4
R(x,y) = 0 if handle(x,y) > threshold and handle(x,y) otherwise.
8
Uses Otsu algorithm for optimal threshold.
16
Uses Triangle algorithm for optimal threshold.
Type: integer

Outputs

computedthreshold
Computed threshold value.
Type: scalar
R
Handle of the resized image.
Type: integer

Example

Apply a threshold to an image:

handle = imreadcv('giraffe.jpg', 0);
[computedthreshold, mask] = thresholdcv(handle, 10, 255, 0);