对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;
}
当然选择这个例子有些讨巧的存在,因为前景为白底红色的文字,这个时候还是比较好进行区分的。同时我还做了一些其他图片的实验。
使用蝴蝶和星空来进行融合



 



posted on   jsxyhelu  阅读(165)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示