问题描述
- opencv调用函数进行阈值二值化为什么会出现中断错误
-
#include "cv.h"
#include
#include "highgui.h"IplImage Thres(IplImage src);
int main(int argc, char** argv)
{IplImage* i; IplImage* ii; i=cvLoadImage("D:\ceshi.jpg"); ii = Thres(i); cvNamedWindow("1",CV_WINDOW_AUTOSIZE); cvNamedWindow("2",CV_WINDOW_AUTOSIZE); cvShowImage("1",i ); cvShowImage("2",ii); cvWaitKey(0); cvDestroyWindow( "1" ); cvDestroyWindow( "2" ); cvReleaseImage( &i); cvReleaseImage( &ii); return 0;
}
IplImage Thres(IplImage src)
{
IplImage* dst;
IplImage* dst = cvCreateImage(cvGetSize(src),src->depth,1);
IplImage* gray;
cvCvtColor(src,dst,CV_RGB2GRAY);
cvThreshold(dst,gray,100,255,CV_THRESH_BINARY);return gray;
}
时间: 2024-12-29 10:58:00