1. 程式人生 > >OpenCV閾值操作

OpenCV閾值操作

#include <opencv2\opencv.hpp>

using namespace cv;

int main() {
	Mat src_image,gray_image, dst_image;
	src_image = imread("D:\\dog.jpg");
	cvtColor(src_image, gray_image, COLOR_RGB2GRAY);
	threshold(gray_image, dst_image, 0, 255, THRESH_BINARY|THRESH_OTSU);
	namedWindow("src", WINDOW_AUTOSIZE);
	namedWindow("THRESH_BINARY", WINDOW_AUTOSIZE);
	imshow("src",src_image);
	imshow("THRESH_BINARY", dst_image);
	waitKey(0);
	return 0;
}