반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

adaptiveThreshold 본문

[AI]/openCV

adaptiveThreshold

givemebro 2020. 6. 23. 12:01
반응형
#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

void on_trackbar(int pos, void* userdata) {
	Mat src = *(Mat*)userdata;

	int bsize = pos;

	if (bsize % 2 == 0)bsize--;
	if (bsize < 3)	bsize = 3;

	Mat dst; 
	adaptiveThreshold(src, dst, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, bsize, 5);

	imshow("dst",dst);
}

int main() {
	Mat src = imread("8.jpg", IMREAD_GRAYSCALE);

	if (src.empty()) {
		cerr << "Image load failed!" << endl;
		return -1;
	}

	imshow("src", src);


	namedWindow("dst");
	createTrackbar("Block Size", "dst", 0, 200, on_trackbar, (void*)&src);
	setTrackbarPos("Block Size", "dst", 11);

	waitKey();
	return 0;
}

반응형

'[AI] > openCV' 카테고리의 다른 글

이미지 변형 in python  (0) 2020.06.24
opencv install in python  (0) 2020.06.23
detect workers in C++  (0) 2020.06.23
QRcode read in C++  (0) 2020.06.23
binarization  (0) 2020.06.23
Canny_edge  (0) 2020.06.23
sobel_edge  (0) 2020.06.23
setMouseCallback  (0) 2020.06.23
Comments