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

bro's coding

binarization 본문

[AI]/openCV

binarization

givemebro 2020. 6. 23. 11:37
반응형

이진화

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;

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

	Mat dst;
	threshold(src, dst, pos, 255, THRESH_BINARY);

	imshow("dst", dst);
}

int main(int argc,char * argv[]) {

	Mat src;
	
	if (argc < 2) {
		src = imread("family.jpg", IMREAD_GRAYSCALE);
	}
	else {
		src = imread(argv[1], IMREAD_GRAYSCALE);
	}

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

	imshow("src", src);

	namedWindow("dst");
	createTrackbar("Threshold", "dst", 0, 255, on_thredhold, (void*)&src);
	setTrackbarPos("Threshold", "dst", 128);

	waitKey();
	return 0;
}

반응형

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

opencv install in python  (0) 2020.06.23
detect workers in C++  (0) 2020.06.23
QRcode read in C++  (0) 2020.06.23
adaptiveThreshold  (0) 2020.06.23
Canny_edge  (0) 2020.06.23
sobel_edge  (0) 2020.06.23
setMouseCallback  (0) 2020.06.23
affine_transform in C++  (0) 2020.06.22
Comments