This can be achieved through a convex hull operation (for shape that have holes or multiple islands; for shapes like the heart, computing its convex hull will not return exactly return the shape you’re looking for).
This functionality is provided by a few Processing libraries including my own, Processing Geometry Suite.