資源簡介
岡薩雷斯的數字圖像處理孔洞填充方法運行緩慢,寫了個簡略的版本。文檔附帶測試圖片
代碼片段和文件信息
#include?
using?namespace?cv;
Mat?holefill(Mat&?src);
int?main(){
Mat?src?=?imread(“1.png“?0);
namedWindow(“src“?WINDOW_NORMAL);
imshow(“src“?src);
Mat?dst?=?holefill(src);
namedWindow(“dst“?WINDOW_NORMAL);
imshow(“dst“?dst);
waitKey(0);
return?0;
}
Mat?holefill(Mat&?src){
Mat?dst?=?src.clone();
bool?start?=?0;
int?n?=?0;
for?(size_t?i?=?0;?i? if?(start?==?0){
if?(dst.data[i]?==?255){//判斷是否開始填充
if?(dst.data[i?+?1]?==?255)//判斷是否有連續點
continue;
else{
start?=?1;
n?=?0;
continue;
}
}
}
else{
if?(dst.data[i]?==?255)//判斷是否關閉填充
start?=?0;
else{
if?((i?+?1)?%?dst.cols?==?0){//一行只有一個點,刪除之前所填充的點,并且關閉填充
int?j?=?i?-?1;
int?m?=?0;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????18020??2018-09-01?20:03??holefill\1.png
?????文件???????1050??2019-08-26?10:57??holefill\holefill.cpp
?????文件?????????49??2019-08-26?10:59??holefill\Readme.txt
?????目錄??????????0??2019-08-26?10:58??holefill
-----------?---------??----------?-----??----
????????????????19119????????????????????4
評論
共有 條評論