Find the "middle" vector shape?

I have 100 similar shapes (simple vector graphics). How can I find the "average / combined" form of 100 instances?

Thank you, you are

+3


source to share


1 answer


Algorithm proposal

  • Calculate the area of ​​each shape {A}.

  • Find shape {S} with most points {N} (you will have a polygon with N sides)

  • Merge {S} with another form and create the first merged form {M}. Then merge {M} with each other. {M} will dynamically / overwrite / change every time it merges with another shape.


Merge function : pseudocode
First call Merge({S}, {S2})

, then call Merge({M}, {S2})

for the rest of the shapes.

Parameters:
{S1} = shape with most dots;
{S2} = form to merge with;



function Merge({S1}, {S2}):    

FOR EACH {point} of {S1} DO
    {near}=find nearest {S2}{point}
    {size}=( SQRT({S1}{A}) + SQRT({S2}{A}) )/2
    {line}=create line starting at {near}, going to/over {point} of length {size}
    add point in {M} with position at half the {line}
END FOR
RETURN {M}
;

      

3 initial shapes: rectangle, triangle, 7 side polygons {S} = green
3shapes

combined green with rectangle {M} = blue
merge1

fused blue with triangle {M} = yellow <-final result final

Please note: the combined shapes are not on the scale! left out areas!

+2


source







All Articles