2014-10-02 40 views

回答

0

我與impainting方法通風口,因爲它是onlything i。從之前的項目了。可能是一些更簡單,但這個工程。

auto a = imread(a_path); 
auto b = imread(b_path); 

std::vector<std::vector<Point> > ca, cb; 
std::vector<Vec4i> ah, bh; 

cv::Mat gray; 
cv::cvtColor(a, gray, COLOR_BGR2GRAY); 
findContours(gray, ca, ah, RETR_EXTERNAL, CHAIN_APPROX_NONE); 

cv::cvtColor(b, gray, COLOR_BGR2GRAY); 
findContours(gray, cb, bh, RETR_EXTERNAL, CHAIN_APPROX_NONE); 

cv::Mat m1 = cv::Mat::zeros(256, 256, CV_8UC1); 
cv::Mat m2 = cv::Mat::zeros(256, 256, CV_8UC1); 
cv::Mat m3 = cv::Mat::zeros(256, 256, CV_8UC1); 

drawContours(m1, ca, 0, 255,-1); 
drawContours(m2, cb, 0, 255,-1); 
bitwise_and(m1, m2, m3); 

cv::Mat c; 
add(a, b,c);  
inpaint(c, m3, c, 5, INPAINT_NS); 

imwrite(c_path, c); 

和繼承人的結果: enter image description here

相關問題