开发者

How to get the Shape of the transparent portion of a BufferedImage in Java?

I have BufferedImage image object开发者_运维技巧s which have transparent pixels. What I'd like to get is Shape or Area objects which enclose the transparent portion of the image.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜