Applies a fixed-level threshold to each array element.
-
C++:
double
threshold
(InputArray
src, OutputArray
dst, double
thresh, double
maxval, int
type
)
-
-
Python:
cv2.
threshold
(src, thresh, maxval, type
[, dst
]
) → retval, dst
-
-
C:
double
cvThreshold
(const CvArr*
src, CvArr*
dst, double
threshold, double
max_value, int
threshold_type
)
-
-
Python:
cv.
Threshold
(src, dst,
threshold, maxValue,
thresholdType
) → None
-
Parameters: - src – input array (single-channel, 8-bit or 32-bit floating point).
- dst – output array of the same size and type as src.
- thresh – threshold value.
- maxval – maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
- type – thresholding type (see the details below).
The function applies fixed-level thresholdingto a single-channel array. The function is typically used to get abi-level (binary) image out of a grayscale image (compare() couldbe also used for this purpose) or for removing a noise, that is, filteringout pixels with too small or too large values. There are severaltypes of thresholding supported by the function. They are determined by type :
THRESH_BINARY
THRESH_BINARY_INV
THRESH_TRUNC
THRESH_TOZERO
THRESH_TOZERO_INV
Also, the special value THRESH_OTSU may be combined withone of the above values. In this case, the function determines the optimal thresholdvalue using the Otsu’s algorithm and uses it instead of the specified thresh .The function returns the computed threshold value.Currently, the Otsu’s method is implemented only for 8-bit images.
See also





1020

被折叠的 条评论
为什么被折叠?



