opencv2对读书笔记——图像二值化——thresholded函数

opencv中的图像二值化函数threshold函数


其结构


double cv::threshold( //二值化函数
		const CvArr* src, //原始图像
		CvArr* dst,       //输出图像
		double threshold, //阈值
		double max_value, //最大值
		int threshold_type//阈值类型
);

实例代码


#include "cv.h"
#include "highgui.h"

int main()
{
	cv::Mat image= cv::imread("2.jpg",0);
	cv::Mat image1= cv::imread("2.jpg");

	cv::namedWindow("Image");
	cv::imshow("Image",image1);


	cv::Mat thresholded;
	cv::threshold(image,thresholded,90,255,cv::THRESH_BINARY);

	cv::namedWindow("Binary Image");
	cv::imshow("Binary Image",thresholded);
	cv::imwrite("binary.bmp",thresholded);

	cv::waitKey();
	return 0;
}


输出结果




posted on 2017-06-30 21:47  wgwyanfs  阅读(121)  评论(0编辑  收藏  举报

导航