Opencv image fusion

Image fusion seamlessClone, for example, put a wild goose picture into a picture of the sky that has been taken, while achieving background fusion

   // eric++
    string folder =  "./src/photo/";
    // 目标图片
    string src_path = folder + "bird.jpg";
    // 背景图片
    string dst_path = folder + "sky.jpg";

    Mat src = imread(src_path, IMREAD_COLOR);
    Mat dst = imread(dst_path, IMREAD_COLOR);

    // 建立Mask,即目标图片感兴趣的区域,这里定义鸟的图片
    Mat M = 255 * Mat::ones(src.rows, src.cols, src.depth());

    // 设定目标图片,融合后在背景图片的坐标
    // Point center(dst.cols/2,dst.rows/2);
    Point center(dst.cols/3,dst.rows/3);

    // 不同融合方法,呈现不同的效果
    Mat normal_clone;
    Mat mixed_clone;
    Mat monochrome_transfer;

    seamlessClone(src, dst, M, center, normal_clone, NORMAL_CLONE);
    seamlessClone(src, dst, M, center, mixed_clone, MIXED_CLONE);
    seamlessClone(src, dst, M, center, monochrome_transfer, MONOCHROME_TRANSFER);
    imshow("normal_clone",normal_clone);
    imshow("mixed_clone",mixed_clone);
    imshow("monochrome_transfer",monochrome_transfer);

Insert picture description here
Insert picture description here
Insert picture description here
If the shielding layer is placed on the edge of Dayan, the effect is better.


Guess you like

Origin blog.csdn.net/pyt1234567890/article/details/109723972