标签:waitkey ext pre val 阈值操作 ssi 阈值 ima color
////Source Code:https://blog.csdn.net/gone_huilin/article/details/53222764 #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" int main() { // 图像读取及判断 cv::Mat srcImage = cv::imread("D:\\0604.png"); if (!srcImage.data) return 1; // 灰度转换 cv::Mat srcGray; cv::cvtColor(srcImage, srcGray, CV_RGB2GRAY); cv::imshow("srcGray", srcGray); cv::Mat dstImage; // 初始化自适应阈值参数 int blockSize = 5; int constValue = 10; const int maxVal = 255; /* 自适应阈值算法 0:ADAPTIVE_THRESH_MEAN_C 1: ADAPTIVE_THRESH_GAUSSIAN_C 阈值类型 0: THRESH_BINARY 1: THRESH_BINARY_INV */ int adaptiveMethod = 0; int thresholdType = 1; // 图像自适应阈值操作 cv::adaptiveThreshold(srcGray, dstImage, maxVal, adaptiveMethod, thresholdType, blockSize, constValue); cv::imshow("dstImage", dstImage); cv::waitKey(0); return 0; }
标签:waitkey ext pre val 阈值操作 ssi 阈值 ima color
原文地址:https://www.cnblogs.com/thebreakofdawn/p/9467359.html