增加图像对比度

/**
 * @@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);
	}


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值