Reputation: 4280
I have BufferedImage
image objects which have transparent pixels. What I'd like to get is Shape
or Area
objects which enclose the transparent portion of the image.
Upvotes: 2
Views: 188
Reputation: 3207
You could try it that way: treat the original image as an undirected graph whose nodes are the transparent pixels. Put an edge between adjacent nodes on the image (i.e. transparent pixels that are directly above, left, right, below, and diagonal). Find the connected components for that graph. Then for each connected component, compute its convex hull. Return a List
containing each of those hulls, each hull being a Shape
.
Upvotes: 1