#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
IplImage* pImg;
IplImage* QQ; //声明IplImage指针
//载入图像
if( argc == 2 &&
(pImg = cvLoadImage( argv[1], 1)) != 0 )
{
cvNamedWindow( "Image", 1 );//创建窗口
cvShowImage( "Image", pImg );//显示图像
cvWaitKey(0); //等待按键
cvDestroyWindow( "Image" );//销毁窗口
cvReleaseImage( &pImg ); //释放图像
return 0;
}
else if( argc == 3 && (pImg = cvLoadImage( argv[1], 1)) != 0 )
{IplImage * QQ = cvCreateImage( cvGetSize(pImg), 8, 3);
IplImage* pImg2 = cvCreateImage(cvGetSize(QQ),
pImg->depth,
pImg->nChannels);
cvCopy(pImg, pImg2, NULL);
cvSaveImage(argv[2], pImg2);//把图像写入文件
cvNamedWindow( "Image", 1 );//创建窗口
cvShowImage( "Image", pImg );//显示图像
cvWaitKey(0); //等待按键
cvDestroyWindow( "Image" );//销毁窗口
cvReleaseImage( &pImg ); //释放图像
cvReleaseImage( &pImg2 ); //释放图像
return 0;
}
return -1;
}
评论4
最新资源