identify contours in a image which are having same color using opencv or javacv?

邮差的信 提交于 2020-01-01 19:57:12

问题


This question is related to my previous question in that question I used color image as input and it identify by using line color but I like to know how to identify that kind of image using gray-scale image. This is the gray-scale input image and have to identify

And I need to identify following objects with its positions (x and y coordinates).

Please can some one explain with simple code example to identify those objects and I need to identify connected lines of those objects as well (As shown in following image).

Please be kind enough to explain this using simple code example.


回答1:


The concept of solution is the same as with previous question - use dilate and erode:

Mat src = imread("input.jpg"), tmp;

cvtColor(src, tmp, CV_BGR2GRAY);
threshold(tmp, tmp, 200, 255, THRESH_OTSU);

Mat element = getStructuringElement(MORPH_RECT, Size(3, 3), Point(1, 1));
dilate(tmp, tmp, element);
erode(tmp, tmp, element);

Result:



来源:https://stackoverflow.com/questions/12088176/identify-contours-in-a-image-which-are-having-same-color-using-opencv-or-javacv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!