opencv 例子2 厚道 发表于 2005-5-26 9:57:00
2、将图像改变为指定大小 ////////////////////////////////////////////////////////////////////////////// // // 程序在一的基础上只是改动了一下cvCvtColor为cvResize(src,dest,method) // 特别注意dest要先创建,而且创建的时候厨大小外其他应该和src都一样才 // 行。src大小并不改变,dest为src擦样得来。 ////////////////////////////////////////////////////////////////////////////// #i nclude "stdafx.h" #i nclude "cv.h" #i nclude "highgui.h"
int main(int argc, char* argv[]) { IplImage *image; IplImage *result;
image=cvLoadImage("c:\\friend.jpg",-1); int channel=image->nChannels; int depth=image->depth; CvSize sz; sz.width=800; sz.height=600;//image->height; result=cvCreateImage(sz,depth,channel); cvResize(image,result);//,CV_BGR2GRAY); cvSaveImage("c:\\resize.jpg",image); cvNamedWindow("original",1); cvShowImage("original",image); cvNamedWindow("gray",1); cvShowImage("gray",result); cvWaitKey(0); cvReleaseImage(&image); cvReleaseImage(&result);
return 0; }
|