int main( int argc, char** argv )
{
IplImage* pImg; //声明IplImage指针
//载入图像,强制转化为Gray
if( argc == 3 &&
(pImg = cvLoadImage( argv[1], 0)) != 0 )
{
IplImage* pImg2 = cvCreateImage(cvGetSize(pImg),
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;
}