您的位置:首页 > 其它

书上的例子运行不出来,有谁可以解答下阿

2011-05-14 22:46 513 查看
#include <cv.h>
#include <highgui.h>
#include <math.h>
#include <stdio.h>
IplImage *Igray=0, *It = 0, *Iat;
int main( int argc, char** argv )
{
char* filename1="C://Program Files (x86)//OpenCV//LearningOpenCV_Code//LearningOpenCV_Code//HandOutdoorSunColor.jpg";
if(argc != 7){return -1; }
//Command line
double threshold = (double)atof("100");
int threshold_type = atoi("0") ?
CV_THRESH_BINARY : CV_THRESH_BINARY_INV;
int adaptive_method = atoi("0") ?
CV_ADAPTIVE_THRESH_MEAN_C : CV_ADAPTIVE_THRESH_GAUSSIAN_C;
int block_size = atoi("100");
double offset = (double)atof("100");
//Read in gray image
if((Igray = cvLoadImage( filename1, CV_LOAD_IMAGE_GRAYSCALE)) == 0){
return -1;}
// Create the grayscale output images
It = cvCreateImage(cvSize(Igray->width,Igray->height),
IPL_DEPTH_8U, 1);
Iat = cvCreateImage(cvSize(Igray->width,Igray->height),
IPL_DEPTH_8U, 1);
//Threshold
cvThreshold(Igray,It,threshold,255,threshold_type);
cvAdaptiveThreshold(Igray, Iat, 255, adaptive_method,
threshold_type, block_size, offset);
//PUT UP 2 WINDOWS
cvNamedWindow("Raw",1);
cvNamedWindow("Threshold",1);
cvNamedWindow("Adaptive Threshold",1);
//Show the results
cvShowImage("Raw",Igray);
cvShowImage("Threshold",It);
cvShowImage("Adaptive Threshold",Iat);
cvWaitKey(0);
//Clean up
cvReleaseImage(&Igray);
cvReleaseImage(&It);
cvReleaseImage(&Iat);
cvDestroyWindow("Raw");
cvDestroyWindow("Threshold");
cvDestroyWindow("Adaptive Threshold");
return(0);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐