问题描述
我想知道是否可以裁剪出具有指定颜色的图像区域?
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 I want to remove the "canvas" area and be left only with the actual image.
欢呼
推荐答案
如果您的图片具有明显区别",请从此 answer 背景色,请使用 LookupOp
具有四个组成部分的LookupTable,用于将与背景色匹配的颜色的alpha组成部分设置为零."
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."
附录:另请参见 使用Java 2D LookupOp过滤器类来处理图像 和 使用Java 2D进行图像处理 .
Addendum: See also Using the Java 2D LookupOp Filter Class to Process Images and Image processing with Java 2D.
这篇关于Java:从图像中裁剪出具有特定颜色的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!