问题
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