您的位置:首页 > 运维架构

Opencv学习——图像融合

2017-10-08 11:06 976 查看
Opencv相关函数:

C++: void seamlessClone(InputArray src, InputArray dst, InputArray mask, Point p, OutputArray blend, int flags)


图像融合基本原理:泊松克隆,与图像的梯度和散度相关,具体的原理可查看

http://blog.csdn.net/hjimce/article/details/45716603

图像融合效果:



其中,原图如下:



相关代码:

int main()
{
// Read images : src image will be cloned into dst
Mat src = imread("bird.jpg");
Mat dst = imread("sunset.jpg");
resize(dst, dst, Size(dst.cols/2, dst.rows/2));

// Create an all white mask
Mat src_mask = Mat::zeros(src.rows, src.cols, src.depth());

// Define the mask as a closed polygon
Point poly[1][4];
poly[0][0] = Point(263, 127);
poly[0][1] = Point(257, 265);
poly[0][2] = Point(720, 338);
poly[0][3] = Point(721, 138);

const Point* polygons[1] = { poly[0] };
int num_points[] = { 4 };

// Create mask by filling the polygon
fillPoly(src_mask, polygons, num_points, 1, Scalar(255, 255, 255));

// The location of the center of the src in the dst
Point center(700, 150);

// Seamlessly clone src into dst and put the results in output
Mat output;
seamlessClone(src, dst, src_mask, center, output, NORMAL_CLONE);

imshow("result", output);
waitKey(0);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  opencv 图像处理