简体   繁体   中英

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

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.

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:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM