alpha融合出错,谁帮我看一下什么原因

Figowt 2012-02-16 12:59:00
#include "highgui.h"
#include "cv.h"
#include "stdio.h"


int main()
{
IplImage *p10=cvLoadImage("d:\\8.jpg",1);
IplImage* p1 = cvCreateImage( cvSize( p10->width,p10->height ), p10->depth, 1);
IplImage *p20=cvLoadImage("d:\\3.jpg",1);
IplImage* p2 = cvCreateImage( cvSize( p20->width,p20->height ), p20->depth, 1);
cvCvtColor(p10,p1 ,CV_BGR2GRAY);
cvCvtColor(p20,p2 ,CV_BGR2GRAY);
int x=100;
int y=200;
int width=30;
int height=36;
double alpha=0.4;
double beta=0.6;
cvSetImageROI(p1,cvRect(x,y,width,height));
cvSetImageROI(p1,cvRect(0,0,width,height));
cvAddWeighted(p1,alpha,p2,beta,0.0,p1);
cvResetImageROI(p1);
cvResetImageROI(p2);;
cvNamedWindow("show",CV_WINDOW_AUTOSIZE);
cvShowImage("show",p1);
cvWaitKey(0);
cvReleaseImage(&p1);
cvReleaseImage(&p2);
cvDestroyWindow("show");
return 0;


}

调试没出错,运行出现下面错误...什么原因啊图读的不对?


OpenCV Error: Sizes of input arguments do not match (The operation is neither 'a
rray op array' (where arrays have the same size and the same number of channels)
, nor 'array op scalar', nor 'scalar op array') in unknown function, file c:\Use
rs\vp\work\ocv\opencv\modules\core\src\arithm.cpp, line 1227
请按任意键继续. . .


...全文
270 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengbingchun 2012-02-20
  • 打赏
  • 举报
回复
\opencv\modules\core\src\arithm.cpp, line 1227
打开arithm.cpp文件看看具体错误
ROI必须统一尺寸
libing64 2012-02-17
  • 打赏
  • 举报
回复
cvSetImageROI(p1,cvRect(x,y,width,height));
cvSetImageROI(p1,cvRect(0,0,width,height));
cvAddWeighted(p1,alpha,p2,beta,0.0,p1);

p2没有设置ROI~

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧