opencv中的二值化函数是什么方法
1个回答
展开全部
//将标记处改成如下即可:
#include "stdafx.h"
//#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int main(int argc,char** argv)
{
IplImage *src=cvLoadImage("D:\\Lena.jpg",0);
if(src==NULL)
{
return 0;
}
cvNamedWindow("src", CV_WINDOW_AUTOSIZE);
cvShowImage("src", src);
IplImage *dst1_img=cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,1);
cvSmooth (src, dst1_img, CV_GAUSSIAN, 11, 0, 0, 0);
cvNamedWindow ("Gaussian", CV_WINDOW_AUTOSIZE);
cvShowImage ("Gaussian", dst1_img);
IplImage *adaptive_img = cvCreateImage(cvGetSize(dst1_img),IPL_DEPTH_8U,1);
cvAdaptiveThreshold(dst1_img, adaptive_img, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 7, 8); //函数改成这样即可
cvNamedWindow ("adaptive", CV_WINDOW_AUTOSIZE);
cvShowImage ("adaptive", adaptive_img);
waitKey();
return 0;
#include "stdafx.h"
//#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
using namespace cv;
int main(int argc,char** argv)
{
IplImage *src=cvLoadImage("D:\\Lena.jpg",0);
if(src==NULL)
{
return 0;
}
cvNamedWindow("src", CV_WINDOW_AUTOSIZE);
cvShowImage("src", src);
IplImage *dst1_img=cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,1);
cvSmooth (src, dst1_img, CV_GAUSSIAN, 11, 0, 0, 0);
cvNamedWindow ("Gaussian", CV_WINDOW_AUTOSIZE);
cvShowImage ("Gaussian", dst1_img);
IplImage *adaptive_img = cvCreateImage(cvGetSize(dst1_img),IPL_DEPTH_8U,1);
cvAdaptiveThreshold(dst1_img, adaptive_img, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 7, 8); //函数改成这样即可
cvNamedWindow ("adaptive", CV_WINDOW_AUTOSIZE);
cvShowImage ("adaptive", adaptive_img);
waitKey();
return 0;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询