I want to:
Simplify a set of points that outlines a closed opaque image on a transparent background.
The simplified set of points should not intrude into the closed opaque image.
I use a Marching Squares Algorithm to fetch a set of points (x,y) that outlines the opaque pixels of an image. This gives a valid set of points outlining the opaque image.
Original image (an opaque sun image on a transparent background):
Result of Marching Squares Algorithm (a set of points--red, around the opaque sun):
This set of points is fine--entirely outside the sun (no intrusion). But the current set of points contains many points that can be eliminated because they are redundant. The redundant points are on the line segment connecting the previous and next point in the set.
For example in the illustration below, the middle red point is redundant and can be eliminated because connecting the first and last points results in the same line segment:
I've tried several path-point simplification algorithms like the Douglas-Peucker Algorithm. This algorithm does reduce points, but it also lets the simplified path intrude into the original image.
For example in the illustration below, the middle point has been eliminated but the result causes the path to intrude into the image:
I have an array containing all pixel colors on the image, so this array can be used to determine if any pixel is transparent (outside the image) or opaque (inside the image).
I'm looking for an algorithm to simplify the path-points which does not let the resulting path intrude into the original image.