資源簡介
這是09年patchmatch和07年圖像補全的代碼, 是我上一個圖像補全代碼的改進版, 但和ps還是有差距。

代碼片段和文件信息
#include?“../patch/patchmatch.h“
int?main()
{
Mat?Src?=?imread(“picture/harvest.png“);
Mat?Mask?=?Mat(Src.size()?CV_8UC1?Scalar::all(0));
Mat?Search?=?Mat(Src.size()?CV_8UC3?Scalar::all(0));
for?(int?i?=?0;?i for?(int?j?=?0;?j if?(Src.at(i?j)?==?Vec3b(0?0?0))
{
Mask.at(i?j)?=?hole;
}
else
Mask.at(i?j)?=?search;
for?(int?i?=?0;?i for?(int?j?=?0;?j if?(Mask.at(i?j)?==?search)
Search.at(i?j)?=?Src.at(i?j);
imshow(“src“?Src);
imshow(“mask“?Mask);
imshow(“search“?Search);
waitKey();
int?ps?=?5;
int?py?=?4;
int?an?=?3;
//erode
Mat?Mask0?=?Mask.clone();
for?(int?i?=?0;?i {
for?(int?j?=?0;?j {
if?(Mask.at(i?j)?==?hole)
{
int?e_s?=?3*ps;
int?r_b?=?i-e_s/2>0??i-e_s/2:0;
int?r_e?=?i+e_s/2
int?c_b?=?j-e_s/2>0??j-e_s/2:0;
int?c_e?=?j+e_s/2
for?(int?k?=?r_b;?k for?(int?p?=?c_b;?p Mask0.at(k?p)?=?hole;
}
}
}
Search.setTo(0);
for?(int?i?=?0;?i for?(int?j?=?0;?j if?(Mask0.at(i?j)?==?search)
Search.at(i?j)?=?Src.at(i?j);
imshow(“src“?Src);
imshow(“mask“?Mask);
imshow(“search“?Search);
waitKey();
init_patch(Src?Mask0?ps?py?an);
run();
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4935??2014-12-19?16:17??222\patch2\ann.h
????.......?????????0??2009-08-31?02:32??222\patch2\ann2.h
?????文件???????4819??2014-12-18?23:02??222\patch2\generate.h
?????文件???????1503??2014-11-25?22:00??222\patch2\harvest.cpp
?????文件???????1770??2014-12-15?12:59??222\patch2\harvest2.cpp
?????文件???????1546??2014-12-18?23:02??222\patch2\init.h
?????文件???????3378??2014-12-15?22:21??222\patch2\meanshift.h
?????文件???????1817??2014-12-18?23:02??222\patch2\meanshitft.h
?????文件???????1499??2014-12-15?12:58??222\patch2\multiob
?????文件??????44032??2014-12-19?16:20??222\patch2\patch2.exe
?????文件???????4436??2014-12-18?20:30??222\patch2\patch2.vcxproj
?????文件???????1593??2014-12-18?20:30??222\patch2\patch2.vcxproj.filters
?????文件????????143??2014-11-22?14:36??222\patch2\patch2.vcxproj.user
?????文件???????2093??2014-12-19?16:20??222\patch2\patchmatch.h
?????文件?????608351??2013-11-20?02:44??222\patch2\picture\harvest.png
?????文件?????248344??2013-11-20?02:44??222\patch2\picture\multiob
?????文件?????139074??2013-11-20?02:44??222\patch2\picture\window.png
?????文件???????3501??2014-12-18?23:02??222\patch2\pyr.h
?????文件?????774384??2014-12-18?20:52??222\patch2\re.png
?????文件???????1285??2014-12-18?23:02??222\patch2\tool.h
?????文件???????1574??2014-12-15?00:14??222\patch2\window.cpp
?????文件????????885??2014-11-22?14:36??222\patch2.sln
????..A..H.?????55808??2015-01-09?20:44??222\patch2.suo
????..AD...?????????0??2014-12-15?13:04??222\patch2\picture
?????目錄??????????0??2015-03-15?18:55??222\patch2
?????目錄??????????0??2015-03-15?18:55??222
-----------?---------??----------?-----??----
??????????????1906770????????????????????26
- 上一篇:基于verilog的數字鐘實現
- 下一篇:STM32L152程序模板
評論
共有 條評論