#include <cv.h> #include <highgui.h> int main(int argc, char** argv) { IplImage *src1,*src2; if (((src1 = cvLoadImage("001.jpg", 1)) != 0) && ((src2 = cvLoadImage("002.jpg", 1)) != 0)) { int x = 850; int y = 100; int width = 200; int height = 200; int add = 50; double alpha = 0.8; double bete = 0.2; //给定图片的从左上角(x,y) 长宽为width,height的区域进行ROI增加像素 cvSetImageROI(src1, cvRect(x, y, width, height)); cvSetImageROI(src2, cvRect(910, 20, width, height)); cvAddWeighted(src1, alpha, src2, bete, 0.0, src1); //增加像素 并且存储在src //释放基于给定矩形的ROI cvResetImageROI(src1); //创建窗口 cvNamedWindow("main1", 1); //cvNamedWindow("main2", 1); //通过新建的窗口对src进行show cvShowImage("main1", src1); //cvShowImage("mian2", src2); cvWaitKey(); cvReleaseImage(&src1); cvReleaseImage(&src2); cvDestroyWindow("main1"); //cvDestroyWindow("main2"); } return 0; }
时间: 2024-10-25 07:14:25