1 #include <cv.h> 2 3 #include <highgui.h> //图像视频输出/输入头文件 4 5 using namespace std; 6 7 int main() 8 9 { 10 11 IplImage * test,*test_1; 12 13 test = cvLoadImage("6013202130.jpg",0); 14 15 test_1 = cvCreateImage(cvSize((test->width)/2, (test->height)/2), IPL_DEPTH_8U, 1); cvResize(test, test_1, CV_INTER_LINEAR); 16 17 cvNamedWindow("zhang_fei_1", CV_WINDOW_AUTOSIZE); 18 19 cvShowImage("zhangfeio", test_1); 20 21 cvNamedWindow("zhang_fei_2", CV_WINDOW_AUTOSIZE); 22 23 cvShowImage("zhangfei", test); 24 25 cvWaitKey(0);//等待按键 26 27 cvDestroyWindow("zhang_fei_1"); 28 29 cvDestroyWindow("zhang_fei_2"); 30 31 cvReleaseImage(&test);//释放内存。 32 33 cvReleaseImage(&test_1); 34 35 return 0; 36 37 }
把一幅灰度图像的垂直分辨率和水平分辨率都变为原来的一半,生成一副新的图像。