[OpenCV] 閾值處理函式cv::threshold()
阿新 • • 發佈:2019-02-12
這是一個對影象二值化處理的函式,對於給定閾值threshold
,高於該threshold
的畫素點值變為pix0
, 低於該threshold的畫素點值變為pix1
.
double cv::threshold(
cv::InputArray src, //輸入影象
cv::OutputArray dst, //輸出影象
double thresh, //閾值
double maxValue, //最大值
int thresholdType //型別
);
每個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 |