IplImage * img1 = cvLoadImage("111.jpg");
IplImage * img2 = cvLoadImage("222.jpg");
IplImage * img3 = cvLoadImage("333.jpg");
IplImage * img_sum = cvCreateImage(cvGetSize(img1),IPL_DEPTH_32F,3);
cvZero(img_sum);
cvAcc(img1,img_sum);
cvAcc(img2,img_sum);
cvAcc(img3,img_sum);
IplImage * img_sum_gray = cvCreateImage(cvGetSize(img1),IPL_DEPTH_8U,3);
cvConvertScale(img_sum,img_sum_gray,1.0/3.0);
cvNamedWindow("img_sum_gray");
cvShowImage("img_sum_gray",img_sum_gray);
cvWaitKey(3000);
cvSaveImage("img_sum_gray.png",img_sum_gray);
cvDestroyAllWindows();
cvReleaseImage(&img1);
cvReleaseImage(&img2);
cvReleaseImage(&img3);
cvReleaseImage(&img_sum);
cvReleaseImage(&img_sum_gray);
![](https://i-blog.csdnimg.cn/blog_migrate/dd939456e96c1a3c7899f4ef25cd67dd.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/66729ffa164440123ee255058b04716b.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/9605f5b18e9eb25f3faffebf5c892b7a.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/dc0ab49c351879810295603704081c87.jpeg)