We have given a closed shape. The shape is given as a matrix of 0's and 1's. For an example see:
We can think of this image as a coordinate system. For simplicity, let the mid point of the image be the origin that is x=0, y=0 point and the range of x, y coordinates is from -1 to 1.
Our aim is to find a polynomial p(x, y) of degree n such that the set of points satisfying the inequality p(x, y) <= 0 will approximate the given shape.
I have tried two approaches so far but I am not satisfied with the results.
First, I have tried to train a convolutional neural network. I have created 10000 or so random polynomials and created their corresponding shapes and used them as training data.
Second, I have chosen a random polynomial and greedly optimized its coefficients to minimize the number of non-overlapping pixels between the given shape and the shape created by the polynomial.
I am looking for an algorithm to solve this task. Thanks for any suggestions.