首页 > 代码库 > cvThreshold与cvAdaptiveThreshold 阀值化操作与自动阀值化操作

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=http://www.mamicode.com/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;
}


本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539854