Opencv学习——图像融合

8 篇文章 1 订阅
8 篇文章 2 订阅

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;
}
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值