如何从图像中删除某个RGB值?

时间:2015-05-11 12:23:16

标签: java

这个问题我已经被困了一段时间。我的想法或我希望能够做的是采用BufferedImage并检查BufferedImage是否包含某个RGB值。如果它已经给出RGB值,那么我想从图像中完全删除该颜色并使其透明。

以下是我在代码中的想法:

public static BufferedImage grabSubImage(BufferedImage image) { 
    Color backgroundToRemove = new Color(253, 28, 253);
    int width = image.getWidth();
    int height = image.getHeight(); 

    for (int imageWidth = 0; imageWidth < width; imageWidth++) { 
         for (int imageHeight = 0; imageHeight < height; imageHeight++) {
              int pixel = image.getRBG(imageWidth, imageHeight); 
              if (pixel == backgroundToRemove) image.removeBackgroundColor(); //Not an Actual Method           
         }
   }
   return image; 
}

这是我的形象: http://i.stack.imgur.com/faEk1.png

有问题的图像位于:(4,0)或每个框为16宽xx(16 * 4,0)

提前感谢您的帮助!非常感谢!

0 个答案:

没有答案