OPENCV盲打手撕代码默写练习-二值化

#include <bits/stdc++.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
Mat src,dst;
int val=50,typ=0,max_val=255;
void call_back(int,void*){
    threshold(src,dst,val,max_val,typ);
    imshow("dst",dst);
}
int main(  ){
    src=imread("head.jpg",CV_8UC1);
    namedWindow("src");
    imshow("src",src);
    threshold(src,dst,val,max_val,typ);
    namedWindow("dst");
    imshow("dst",dst);
    createTrackbar("threshold_types","src",&typ,6,call_back);
    createTrackbar("threshold_value","src",&val,255,call_back);
    waitKey(0);
	return(0);
}

/*
enum {
    CV_THRESH_BINARY      =0, /// value = value > threshold ? max_value : 0
    CV_THRESH_BINARY_INV  =1, /// value = value > threshold ? 0 : max_value
    CV_THRESH_TRUNC       =2, /// value = value > threshold ? threshold : value
    CV_THRESH_TOZERO      =3, /// value = value > threshold ? value : 0
    CV_THRESH_TOZERO_INV  =4, /// value = value > threshold ? 0 : value
    CV_THRESH_MASK     =7,
    CV_THRESH_OTSU     =8, /// use Otsu algorithm to choose the optimal threshold value;
    THRESH_TRIANGLE    =9, /// use Triangle algorithm to choose the optimal threshold value
};
*/

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值