这是一个对图像二值化处理的函数,对于给定阈值threshold
,高于该threshold
的像素点值变为pix0
, 低于该threshold的像素点值变为pix1
.
double cv::threshold( cv::InputArray src, //输入图像 cv::OutputArray dst, //输出图像 double thresh, //阈值 double maxValue, //最大值 int thresholdType //类型 );
- 1
- 2
- 3
- 4
- 5
- 6
- 7
每个thresholdType
对应不用的操作类型,如下表所示,其中src代表图像原像素值,dst代表处理后的像素值
ThresoldType | Operation |
---|---|
cv::THRESH_BINARY | dst = (src > thresh) ? maxValue : 0 |
cv::THRESH_BINARY_INV | dst = (src > thresh) ? 0 : maxValue |
cv::THRESH_TRUNC | dst = (src > thresh) ? thresh : src |
cv::THRESH_TOZERO | dst = (src > thresh) ? src : 0 |
cv::THRESH_TOZERO_INV | dst = (src > thresh) ? 0 : src |
转载自:https://blog.csdn.net/u014618300/article/details/79910173
这是一个对图像二值化处理的函数,对于给定阈值threshold
,高于该threshold
的像素点值变为pix0
, 低于该threshold的像素点值变为pix1
.
double cv::threshold( cv::InputArray src, //输入图像 cv::OutputArray dst, //输出图像 double thresh, //阈值 double maxValue, //最大值 int thresholdType //类型 );
- 1
- 2
- 3
- 4
- 5
- 6
- 7
每个thresholdType
对应不用的操作类型,如下表所示,其中src代表图像原像素值,dst代表处理后的像素值
ThresoldType | Operation |
---|---|
cv::THRESH_BINARY | dst = (src > thresh) ? maxValue : 0 |
cv::THRESH_BINARY_INV | dst = (src > thresh) ? 0 : maxValue |
cv::THRESH_TRUNC | dst = (src > thresh) ? thresh : src |
cv::THRESH_TOZERO | dst = (src > thresh) ? src : 0 |
cv::THRESH_TOZERO_INV | dst = (src > thresh) ? 0 : src |
转载自:https://blog.csdn.net/u014618300/article/details/79910173