cvThreshold与cvAdaptiveThreshold 阀值化操作与自动阀值化操作

核心函数:cvThreshold,cvAdaptiveThreshold

程序:

wKiom1PsPMezkdUdAAE7lBqnfao434.jpg

代码:

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int AdaptiveThreshold(int argc,char** argv)
{
IplImage* src=cvLoadImage("e:\\picture\\4.jpg",0);
IplImage* dst1=cvCreateImage(cvGetSize(src),src->depth,1);
IplImage* dst2=cvCreateImage(cvGetSize(src),src->depth,1);
cvThreshold(src,dst1,125,255,CV_THRESH_BINARY); //估计阀值
cvAdaptiveThreshold(src,dst2,255,CV_ADAPTIVE_THRESH_GAUSSIAN_C,CV_THRESH_BINARY);  //手动阀值
cvNamedWindow("src");
cvNamedWindow("threshold");
cvNamedWindow("AdaptiveThreshold");
cvShowImage("src",src);
cvShowImage("threshold",dst1);
cvShowImage("AdaptiveThreshold",dst2);
cvWaitKey(0);
cvDestroyWindow("src");
cvDestroyWindow("threshold");
cvDestroyWindow("AdaptiveThreshold");
cvReleaseImage(&src);
cvReleaseImage(&dst1);
cvReleaseImage(&dst2);
return 0;
}


你可能感兴趣的:(opencv,阀值化,自动阀值化)