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!

enter image description here

1 Answers

0
Болат Тлеубаев On Best Solutions

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!