Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In this case of "finding the larger green area", starting from the binary image that you have shown, you can do it in 2 ways:

  1. using fitEllipse
  2. using minAreaRect

The idea is that you have the white spots. Based on this you need to find the contours and then find the minimum fitting ellipse or rectangle (in fact they are both RotatedRect). Then it is simple to compute the area of that contour based on mathematics and just pick the biggest one.

Another thing: because the white regions are having holes, you can do a morphology operation (ex: closing) for making a more compact area.

In this case of "finding the larger green area", starting from the binary image that you have shown, you can do it in 2 ways:

  1. using fitEllipse
  2. using minAreaRect

The idea is that you have the white spots. Based on this you need to find the contours and then find the minimum fitting ellipse or rectangle (in fact they are both RotatedRect). Then it is simple to compute the area of that contour based on mathematics and just pick the biggest one.

Another thing: because the white regions are having holes, you can do a morphology operation (ex: closing) for making a more compact area.


Ok, I shall add: You can also filter based on the eccentricity (or aspect ratio): if the ellipse is very long (or longer_axis/shorter_axis > a_threshold), you shall eliminate it. I have thought of this because of the green regions on the zebra mark, that after closing may get a very big region (and in my opinion very tall).