Please refer attached image. The image has many polygons with different colors. I need to find contour points(ordered) of polygon with specified color. I need to do this in OpenCV. I am new to OpenCV and I looked at various references on internet but they are in some way different from my problem mentioned here. Any help is appreciated. Thank you!
Asked
Active
Viewed 176 times
1 Answers
0
There are many ways to do this, I am going to give you the one I would use.
Extracting binary image of desired colour
In order to focus on a specific colour you may try RGB/HSV thresholding setting top and lower boundaries for a specific colour. Here you can find a nice answer on how to do that.
Extracting contour from binary image
For that you can use findContours() function form OpenCV. It is based on a work of Suzuki and Abe as well as on Moore pixel following algorithm. If you want to know more you can find a more detailed description in documentation of the function.
Arrange contour points as you wish
findCountours() will give you an array of contour points, you can rearrange them in any order you wish.
Hope that will help, good luck!

Bolat Tleubayev
- 1,765
- 3
- 14
- 16
-
1Hello Болат Тлеубаев, Thanks for the answer. I found two more links based on your suggestions - https://pysource.com/2018/03/01/find-and-draw-contours-opencv-3-4-with-python-3-tutorial-19/ and https://www.pyimagesearch.com/2015/04/20/sorting-contours-using-python-and-opencv/ – Vijayendra Apr 22 '19 at 13:49