Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我怎样才能像Photoshop那样将黑色添加到图像中?_Java_Image Processing - Fatal编程技术网

Java 我怎样才能像Photoshop那样将黑色添加到图像中?

Java 我怎样才能像Photoshop那样将黑色添加到图像中?,java,image-processing,Java,Image Processing,我有一个rgb值数组,我想直接修改这些值,而不是使用重缩放,因为这样我有更多的控制权 for (int x = 0; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { int[] rgb = image.getRGB([x][y]); rgb[0] *= Math.pow(2, desiredBri

我有一个rgb值数组,我想直接修改这些值,而不是使用重缩放,因为这样我有更多的控制权

for (int x = 0; x < image.getWidth(); x++) {
            for (int y = 0; y < image.getHeight(); y++) {
                int[] rgb = image.getRGB([x][y]);
                rgb[0] *= Math.pow(2, desiredBrightness);
                rgb[1] *= Math.pow(2, desiredBrightness);
                rgb[2] *= Math.pow(2, desiredBrightness);
            }
}
for(int x=0;x

这是我修改亮度的for循环,我尝试使用类似的for循环来添加黑色,但我无法提出与上面类似的算法。

为此,您需要一种截止方法/功能:您可以找到接近或非常接近黑色的颜色(所有颜色组件都需要低于某个阈值)然后你把它们完全变黑:

addBlacks(int blackThreshold) {
  for (x = 0; x < image.getWidth(); x++) {
    for (y = 0; y < image.getHeight(); y++) {
      int rgb = bim.getRGB(x, y)&0x00ffffff;
      int rr=(rgb&0x00ff0000)>>16, rg=(rgb&0x0000ff00)>>8, rb=rgb&0x000000ff;
    if(rr<blackThreshold && rg<blackThreshold && rb<blackThreshold)
      rr=rg=rb=0;
    b2.setRGB(x, y, 0xff000000|(rr<<16)|(rg<<8)|rb);
  }
}    
addBlacks(int blackThreshold){
对于(x=0;x>16,rg=(rgb&0x0000ff00)>>8,rb=rgb&0x000000ff;

如果“添加黑色”是什么意思?你必须解释explicitly@gpasch在Adobe Bridge中,有一个滑块用于使深色变暗,该滑块被标记为“黑色”虽然对浅颜色的影响很小。这就像对比度一样,但没有对浅颜色进行太多修改。好的,我不使用photoshop等,所以如果你之前有两张图片,我可以理解后在这里发布它们