资源介绍
void CPsView::ImgAdd(IplImage *inputImg,IplImage *inputImg1,IplImage *outputImg,double r)//图像叠加
{
uchar *data= (uchar *)inputImg->imageData;
int wp = inputImg->widthStep;
uchar *data1= (uchar *)inputImg1->imageData;
int wp1 = inputImg1->widthStep;
uchar *data2= (uchar *)outputImg->imageData;
int wp2 = outputImg->widthStep;
for(int i = 0; i < inputImg->height; i++)
{
for(int j = 0; j < inputImg->width; j++)
{
data2[i * wp2 + 3 * j]=(1-r)*data[i * wp + 3 * j]+r*data1[i * wp1 + 3 * j];
data2[i * wp2 + 3 * j + 1]=(1-r)*data[i * wp + 3 * j + 1]+r*data1[i * wp1 + 3 * j + 1];
data2[i * wp2 + 3 * j + 2]=(1-r)*data[i * wp + 3 * j + 2]+r*data1[i * wp1 + 3 * j + 2];
}
}
}
void CPsView::OnImgadd()
{
// TODO: Add your command handler code here
CvvImage img1;
img1.Load("E:\\新建文件夹\\sky.jpg");
IplImage * outputImg=cvCreateImage(cvSize(img1.Width(),img1.Height()), 8, 3);
CPsDoc * pDoc = GetDocument();
ImgAdd(img1.GetImage(),pDoc->m_img.GetImage(),outputImg,0.3);
cvSaveImage("E:\\新建文件夹\\add.jpg",outputImg);
pDoc->m_img.Load("E:\\新建文件夹\\add.jpg");
Invalidate();
}
- 上一篇: 基于SURF算法的图像拼接软件
- 下一篇: OPENCV图像拼接