Say, I have a sprite of a game object which is a png image with transparency.

I want to create a polygon from this image which will contain my game object.

I am pretty sure there is an existing algorithm for it, but I haven't found any.
I expect something like:
public static Polygon getPolygon(BufferedImage sprite)
{
// get coordinates of all points for polygon
return polygon;
}