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