zoukankan      html  css  js  c++  java
  • 对OpenCV中seamlessClone的初步实验

    seamlessClone是OpenCV中新出现的函数,应该说如果能够基于较为准确的图像分割,能够得到很好的结果。

    原始的前景,背景
    三种flag下的融合结果
     
    //注意头文件中添加  #include <opencv2/photo.hpp>
    int main( int argc, const char** argv )
    {
        Mat src = imread("iloveyoupapa.png");
        Mat dst = imread("wood.png");
        // Create an all white mask
        Mat src_mask = 255 * Mat::ones(src.rows, src.cols, src.depth());
        // The location of the center of the src in the dst
        Point center(dst.cols/2,dst.rows/2);
        // Seamlessly clone src into dst and put the results in output
        Mat normal_clone;
        Mat mixed_clone;
        Mat monochrome_clone;
        seamlessClone(src, dst, src_mask, center, normal_clone, NORMAL_CLONE);
        seamlessClone(src, dst, src_mask, center, mixed_clone, MIXED_CLONE);
        seamlessClone(src, dst, src_mask, center, monochrome_clone, MONOCHROME_TRANSFER);
        imshow("normal_clone",normal_clone);
        imshow("minxed_clone",mixed_clone);
        imshow("monochrome_clone",monochrome_clone);
        imshow("wood",dst);
        imshow("lovepapa",src);
        waitKey();
        return 0;
    }
    当然选择这个例子有些讨巧的存在,因为前景为白底红色的文字,这个时候还是比较好进行区分的。同时我还做了一些其他图片的实验。
    使用蝴蝶和星空来进行融合





  • 相关阅读:
    .Net Core小技巧
    调用Kubernetes API操作Kubernetes
    在CentOS 7+ 安装Kubernetes入门(单Master)
    Linux命令行基础
    使用wireshark学习TCP
    Redis原子性写入HASH结构数据并设置过期时间
    Vue使用小结
    JAVA & .NET创建对象构造函数调用顺序
    .NET 中的序列化 & 反序列化
    ASP.NET Core中使用Graylog记录日志
  • 原文地址:https://www.cnblogs.com/jsxyhelu/p/6985288.html
Copyright © 2011-2022 走看看