3
我想試圖找到一種方法來做一個近似的分割墓地圖像(文化科學中的CBIR的背景下 - 但這不是主題)。到目前爲止,我使用這個策略:OpenCV:約。從Contour-Image
- 羅嗦圖像兩次(實驗結果)
- 應用的Canny邊緣探測器
尋找輪廓
int main(int argc, const char* argv[]) { cout << "Starting " << endl; Mat sourceImage; sourceImage = imread("singlesegmentation/DSCN5204.JPG", CV_LOAD_IMAGE_COLOR); if (!sourceImage.data) { cout << "No Image found." << endl; return -1; } cv::Mat blurred = imagePro::blurrNtimes(2, sourceImage); cv::Mat target = edged::applyCanny(blurred); cout << "Canny applied " << endl; vector<vector<Point> > contours; vector<Vec4i> hierarchy; cv::Point offset; offset.x = sourceImage.rows/2; offset.y = sourceImage.cols/2; cv::findContours(target, contours, hierarchy, CV_RETR_TREE , CV_CHAIN_APPROX_SIMPLE, offset); cout << "Contours applied " << endl; int idx = 0; for (; idx >= 0; idx = hierarchy[idx][0]) { Scalar color(rand() & 255, rand() & 255, rand() & 255); drawContours(target, contours, idx, color, CV_FILLED, 8, hierarchy); } cout << "Lines applied " << endl; cv::namedWindow("Contour", CV_WINDOW_NORMAL); cv::imshow("Contour", target); cv::waitKey(0); return 0;
}
名稱空間「imagePro」和「edged」包含簡單的opencv代碼以模糊圖像並進一步處理它。代碼起作用。這裏是一個示例圖片: 但現在我不知道分割圖像。我想從內部走到矩形石的外面,當我找到一條線時,我想記住座標,然後剪切內容。謝謝你,如果你有一個想法或提示!
類Hough變換應用程序,概率性HT也給你端點,並讓你過濾掉太短的行http://docs.opencv.org/modules/imgproc/doc/feature_detection.html#houghlinesp –