Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering out abnormal shapes from a binary image in python opencv

Any ideas for filters I could use to clean the following image up? enter image description here

Perhaps something with a polygonal approximation?

like image 322
Nezo Avatar asked Feb 12 '26 12:02

Nezo


1 Answers

I've had a similar problem. Here is what I did:

  1. Small opening to clean the image from all the small useless patterns (not mandatory in your case)
  2. Connected component labeling.
  3. Separate each component
  4. For each component, compute the geodesic diameter (here is an illustration, and here a paper).
  5. The pattern with the longest diameter is the one you are looking for.

In your case, if the proportions are always the same, then you can simply keep the biggest component.

like image 189
FiReTiTi Avatar answered Feb 14 '26 22:02

FiReTiTi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!