我想采取这个公式:

并将其转换为java代码.我不认为下面的代码是正确的,因为我认为我得到了错误的结果.
return (int)(2 * a * b + Math.pow(a, 2) * (1 - 2 * b));
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的原始图像: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();
Run Code Online (Sandbox Code Playgroud)
柔光:
public static int softLight(int background, int foreground){
return (2 * background * foreground) + ((background * background) * (1 - 2 * foreground));
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1797 次 |
| 最近记录: |