欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Opencv学习——图像融合

程序员文章站 2024-03-21 23:27:46
...

Opencv相关函数:

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

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

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


图像融合效果:

Opencv学习——图像融合
其中,原图如下:
Opencv学习——图像融合


相关代码:

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 图像处理