Skip to content
Advertisement

Draw contours around images of the same color with openCV python

I have this image with 3 channels RGB (a result of a VARI Index computation) and I would like to draw bounding boxes (rectangles) around the plants, represented in green here. What is the best and easiest way to do it with OpenCV / python?

I guess it’s an easy problem for OpenCV experts, but I could not find good tutorials online to do this for multiple objects.

The closest tutorial I found was: determining-object-color-with-opencv

The assumptions for the bounding boxes should/could be:

  • green is the dominant color.
  • it should be more than X pixels.

Thanks in advance!

VARI Index

Advertisement

Answer

Just answering my own question after stumbling upon this resource: https://docs.opencv.org/3.4/da/d0c/tutorial_bounding_rects_circles.html

May not be the best answer but it somehow solves my problem!

JavaScript

enter image description here

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