【发布时间】:2016-06-09 10:50:33
【问题描述】:
我正在寻找一种在手绘草图中找到笔触的方法。我的实际方法是从 OpenCV 应用自适应阈值和 findContours。这个问题是 findContours 给了我右手边和左手边,一个笔画的上轮廓和下轮廓。有没有办法从手绘笔画中导出一个轮廓表示?
提前致谢
已编辑:
这是我到目前为止所取得的代码和图像:
首先我将自适应阈值应用于初始图像:
Imgproc.GaussianBlur(image, image, new Size(5, 5), 3);
Mat thresholded = Mat.zeros(image.size(), CvType.CV_8U);
然后我在阈值图像上应用 findCountours,并在每个轮廓上应用 approxPolyDB。
Imgproc.findContours(thresholded, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0,0));
List<MatOfPoint> refinedContours = new ArrayList<MatOfPoint>();
for (int i = 0; i < contours.size(); i++) {
MatOfPoint2f approx = new MatOfPoint2f();
Imgproc.approxPolyDP(mop2mop2f(contours.get(i)), approx, 6, true);
}
然后,我在角度大于固定阈值的点处分割每个轮廓。作为最后一步,我删除了所有不超过给定阈值的轮廓。
In the picture you can see the thresholded image as the final contours
我的目标是避免出现平行轮廓,使草图中的一个笔画只有一个轮廓。
谢谢
【问题讨论】:
-
您能发布您的代码和示例图片吗?
标签: algorithm opencv computer-vision