opencv之threshold函数

threshold

通常用来筛选符合有个值域内的信息
在这里插入图片描述

在这里插入图片描述
![(https://img-blog.csdnimg.cn/20190708202926204.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjIzNzYxNQ==,size_16,color_FFFFFF,t_70)

在这里插入图片描述

#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;

int main()
{
	Mat src = imread("D:/Teach_turials/learnopencv/Threshold/threshold.jpg",0);
	imshow("0", src);
	Mat dst;

	threshold(src, dst, 0, 255, THRESH_BINARY);
	imwrite("opencv_threshold-example.jpg", dst);
	
	threshold(src, dst, 0, 128, THRESH_BINARY);
	imwrite("opencv_thresh_binary-maxval.jpg",dst);

	threshold(src, dst, 127, 255, THRESH_BINARY);
	imwrite("opencv_thresh-binary.jpg", dst);

	threshold(src, dst, 127, 255, THRESH_BINARY_INV);
	imwrite("opencv_thresh-binary-inv.jpg", dst);

	threshold(src, dst, 127, 255, THRESH_TRUNC);
	imwrite("opencv_thresh-trunc.jpg", dst);

	threshold(src, dst, 127, 255, THRESH_TOZERO);
	imwrite("opencv_thresh-tozero.jpg", dst);

	threshold(src, dst, 127, 255, THRESH_TOZERO_INV);
	imwrite("opencv_thresh-to-zero-inv.jpg", dst);
}

windows中,绝对路径用/表示
windows中,绝对路径用/表示 windows中,绝对路径用/表示

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值