/**
* @@author: CGB
* @notes: //将图像中像素集中在[low,high],低于low的变为low,高于high的为high,并增加映射将low->0,high->255
* @@date: 2022/05/17
* @Method: my_threshold
* @FullName: my_threshold
* @Access: public
* @Returns: void
* @Qualifier:
* @Parameter: const cv::Mat & src
* @Parameter: cv::Mat & dst
* @Parameter: const int & low
* @Parameter: const int & high
* @Parameter: bool flag
*/
void my_threshold(const cv::Mat& src, cv::Mat &dst, const int& low, const int& high, bool flag) {
cv::Mat thresholdImg1, thresholdImg2, thresholdImg3;
cv::threshold(src, thresholdImg1, high, 255, 2);
cv::threshold(thresholdImg1, thresholdImg2, low, low, 1);
cv::threshold(thresholdImg1, thresholdImg3, low, low, 3);
dst = thresholdImg2 + thresholdImg3;
if (flag) {
dst -= low;
cv::Mat lookUpTable(1, 256, CV_8U);
uchar* p = lookUpTable.ptr();
for (int i = 0; i < 256; ++i)
p[i] = cv::saturate_cast<uchar>(255.0 / (high - low + 1)*i);
LUT(dst, lookUpTable, dst);
}
}
增加图像对比度
最新推荐文章于 2023-06-17 14:49:15 发布