1. 程式人生 > >對OpenCV中seamlessClone的初步實驗

對OpenCV中seamlessClone的初步實驗

enter mage chrome .cn span text left clone dst

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;
} 當然選擇這個例子有些討巧的存在,因為前景為白底紅色的文字,這個時候還是比較好進行區分的。同時我還做了一些其他圖片的實驗。 使用蝴蝶和星空來進行融合 技術分享 技術分享





對OpenCV中seamlessClone的初步實驗