开发者

Java: Crop out an area with specific color from an image

开发者 https://www.devze.com 2023-01-12 14:29 出处:网络
I was wondering if there is a way to crop out an area of an image with a specified color? I have an image which is a canvas area with an actual image on it and开发者_StackOverflow社区 I want to remov

I was wondering if there is a way to crop out an area of an image with a specified color?

I have an image which is a canvas area with an actual image on it and开发者_StackOverflow社区 I want to remove the "canvas" area and be left only with the actual image.

Cheers


From this answer, if your image has a "distinct background color, use a LookupOp with a four-component LookupTable that sets the alpha component to zero for colors that match the background."

Addendum: See also Using the Java 2D LookupOp Filter Class to Process Images and Image processing with Java 2D.

0

精彩评论

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