4

I'm just going to try and explain my problem with images:

The program receives an input (image):

enter image description here

There is a base polygon, but can be simplified into a circle in all situations:

enter image description here

Output should be something like:

enter image description here

There is no correct result, just good and bad ones.

To make things easier, an estimate how many circles there should be can be given based on the surface and extent of the polygon.

What I am searching is an algorithm that does something described above - cover as much as possible with the given shape, while minimizing the area of black pixels and overlapping areas.

Jaka Konda
  • 1,385
  • 3
  • 13
  • 35

1 Answers1

1

I used k-means clustering to find circle centers. Number of clusters is calculated:

numberOfClusters = round(polygonArea / basePolygonArea).

Input data for k-means algorithm are points of white pixels.

Jaka Konda
  • 1,385
  • 3
  • 13
  • 35
  • Hi @Jaka Konda - can u provide a bit more detailed solution that u used? I have similar problem - I need to position evenly circles on selected polygon on map. – hbk Jun 23 '21 at 10:12
  • @hbk, poking at ghosts. I'll try to find the code later during the day, it will be outdated anyway. Bu0t as I recall I simply iterated over all the pixels, if it was white stored it in a vector/cv::Array2d and then forwarded it to the k-means with with the expected number of clusters calculated with the formula from my answer. The output are the centers. In my case, the circles were of fixed diameter so k-means was appropriate. – Jaka Konda Jun 24 '21 at 06:45