我想采用这个公式:
并将其转换为java代码。我不认为下面的代码是正确的,因为我认为我得到了错误的结果。
return (int)(2 * a * b + Math.pow(a, 2) * (1 - 2 * b));
这是我正在使用的原始图像:http: //images2.fanpop.com/images/photos/4800000/Beach-beaches-4843817-1280-800.jpg
a = 图片链接的反转
b = 图片链接
以下是我期望的输出结果(PhotoShop):
这就是我的输出实际的样子(我的应用程序):
Invert inv = new Invert();
inv.setStage(stage);
inv.setParent(this);
BufferedImage img = inv.filter();
int[] invPixels = new int[stage.width * stage.height];
img.getRGB(0, 0, stage.width, stage.height, invPixels, 0, stage.width);
for(int i = 0; i < ImageSync.originalPixels.length; i++){
int fg = invPixels[i];
int bg = ImageSync.originalPixels[i];
int color = Blends.softLight(fg, bg);
invPixels[i] = color;
}
img = new BufferedImage(stage.width, stage.height, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, stage.width, stage.height, invPixels, 0, stage.width);
Preview.setImage(img);
stage.preview = Preview.getImage();
this.repaint();
柔光:
public static int softLight(int background, int foreground){
return (2 * background * foreground) + ((background * background) * (1 - 2 * foreground));
}