Lance Pollard
Lance Pollard

Reputation: 79248

Simplifying a set of shapes into a single shape

Given you have a bunch of shapes, say like this:

enter image description here

Wondering if there is a real-time algorithm out there (or any suggestions would be helpful too) that can identify that you can approximate that with large circles sort of like this:

enter image description here

It doesn't have to be circles specifically, it can be parameterized to work in different ways. Just wondering how to basically:

  1. Identify a chunk of shapes that can be approximated by a simpler shape.
  2. Overlay that shape on top of the more complex/smaller shapes.

Thank you.

Upvotes: 0

Views: 121

Answers (1)

Bassem
Bassem

Reputation: 820

I think of an approach. I would call it Changing Contrast/Brightness as in image edit applications.

  1. you get all the centers of your shapes.
  2. get their volumes.
  3. calculate the weight of each shape (function of distance and volume of each other shape. Wx = F(Di, Vi), where W (Weight), x: your current shape index, D (distance), Di the distance between x and i, V (Volume), Vi : the volume of i.
  4. Have a variable (perhaps a value scroll bar) to change the Brightness.
  5. repeat #4 for Contrast.
  6. Calculate the average (or mean average) of Weight of all shapes.

Increasing the Brightness means decreasing the volume of far shapes (i.e. shapes with weight below the average "low weight").

Increasing the contrast means increase volume of shapes of high weight and decrease low weights.

By changing both contrast and brightness, some shapes will disappear, others will join as one shape, and you will get a simpler shape(s).

Upvotes: 1

Related Questions