Skip to content
Advertisement

how to mark the labels on image using watershed opencv

As this is the output from the watershed and I want to mark the labels like 1,2,3 etc on the regions identified. I have tried to use cv2.puttext as well by using cv2.boudingrect but the labels are not coming in the center of the region identified

1

JavaScript

Through the above code the generated labels are as follows

2

What i want is that to mark the labels 3,4,5 etc in the center of the objects identified by watershed.

Advertisement

Answer

You can find the center of each region like this:

JavaScript

The result:

enter image description here

Complete example:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement