OpenCV_Add方法

View Code
 1  //ROI的蓝色通道增加150灰度值效果
2 IplImage* src;
3 if((src=cvLoadImage("fruit.jpg",1))!=0)
4 {
5 int x=10;
6 int y=20;
7 int width=50;
8 int height=100;
9 int add=150;
10 cvSetImageROI(src,cvRect(x,y,width,height));
11 cvAddS(src,cvScalar(add),src);
12 cvResetImageROI(src);
13 cvNamedWindow("roi_add",1);
14 cvShowImage("roi_add",src);
15
16
17 }
18
19 //addweighted函数调用
20 IplImage *src1,*src2,*dst;
21
22 if((src1=cvLoadImage("zl.jpg"))!=0&&(src2=cvLoadImage("w.jpg"))!=0)
23 {
24 int x1 = 685;
25 int y1 = 250;
26 int x2=315;
27 int y2=230;
28
29 double alpha=0.2f;
30 double beta=0.8f;
31
32 cvNamedWindow("src1",1);
33 cvSetImageROI(src1,cvRect(x1,y1,200,200));
34 cvSetImageROI(src2,cvRect(x2,y2,200,200));
35 cvNamedWindow("alpha_blend",1);
36 cvShowImage("src1",src1);
37 cvAddWeighted(src1,alpha,src2,beta,0.0,src1);
38 cvShowImage("alpha_blend",src1);
39 cvWaitKey();
40
41 }

posted on 2011-09-30 15:27  Ming明、  阅读(1609)  评论(0编辑  收藏  举报