opencv trackbar binary image threshold

xiaoxiao2025-04-11  22

// // Created by shanghaitech on 18-10-28. // #include<opencv2/imgproc/imgproc.hpp> #include<opencv2/highgui/highgui.hpp> #include<iostream> using namespace std; using namespace cv; Mat srcImage; int pos = 0; void onChangeTrackBar(int, void *) { Mat dstImage; threshold(srcImage, dstImage, pos, 255, THRESH_BINARY); imshow("threshold2", dstImage); } int main() { srcImage = imread("/home/Pictures/part.png"); if (!srcImage.data){ cout << "read failed" << endl; system("pause"); return -1; } Mat srcGray; cvtColor(srcImage, srcGray, CV_RGB2GRAY); namedWindow("threshold");//创建窗口 imshow("threshold", srcGray); //创建滑动条createTrackbar createTrackbar("pos", "threshold", &pos, 255, onChangeTrackBar); waitKey(0); return 0; }

 

转载请注明原文地址: https://www.6miu.com/read-5027995.html

最新回复(0)