android - android java中的图像颜色校正

标签 android image colors

我正在编写一个程序,允许用户比较 2 张照片,其中 1 张作为样本颜色,另一张进行编辑。我将从第一个收集像素信息,然后应用以下方法编辑后者。

结果照片:http://www.flickr.com/photos/92325795@N02/8392038944/in/photostream

我的照片正在更新,尽管质量/噪点/颜色不佳,但到处都有奇怪的颜色。任何人都知道我应该怎么做才能删除它?或者更好地改进我正在使用的方法?继承人的代码:

输入是要编辑的位图,inColor是要编辑的照片中 Nose 的颜色,reqcolor是样本/最佳照片中我 Nose 的颜色。

public Bitmap shiftRGB(Bitmap input, int inColor, int reqColor){

    int deltaR = Color.red(reqColor) - Color.red(inColor);
    int deltaG = Color.green(reqColor) - Color.green(inColor);
    int deltaB = Color.blue(reqColor) - Color.blue(inColor);

    //--how many pixels ? --
    int w = input.getWidth();
    int h = input.getHeight();


    //-- change em all! --
    for (int i = 0 ; i < w; i++){
        for (int  j = 0 ; j < h ; j++ ){
            int pixColor = input.getPixel(i,j);

            //-- colors now ? --
            int inR = Color.red(pixColor);
            int inG = Color.green(pixColor);
            int inB = Color.blue(pixColor);

            if(inR > 255){ inR = 255;}
            if(inG > 255){ inG = 255;}
            if(inB > 255){ inB = 255;}
            if(inR < 0){ inR = 0;}
            if(inG < 0){ inG = 0;}
            if(inB < 0){ inB = 0;}

            //-- colors then --
            input.setPixel(i,j,Color.argb(255,inR + deltaR,inG + deltaG,inB           + deltaB));
        }
    }

    return input;

} 非常感谢你帮助我!除了提前再说声谢谢,我无法表达我的感激之情!

最佳答案

该功能似乎按预期工作。

但是,我确实注意到的一件事是,在实际设置新像素的最终输出之前,您将“if”案例用于验证边界。

        if(inR > 255){ inR = 255;}
        if(inG > 255){ inG = 255;}
        if(inB > 255){ inB = 255;}
        if(inR < 0){ inR = 0;}
        if(inG < 0){ inG = 0;}
        if(inB < 0){ inB = 0;}
        input.setPixel(i,j,Color.argb(255,inR + deltaR,inG + deltaG,inB + deltaB));

我相信这就是您实际想要做的。

        inR += deltaR
        inG += deltaG
        inB += deltaB
        if(inR > 255){ inR = 255;}
        if(inG > 255){ inG = 255;}
        if(inB > 255){ inB = 255;}
        if(inR < 0){ inR = 0;}
        if(inG < 0){ inG = 0;}
        if(inB < 0){ inB = 0;}
        input.setPixel(i,j,Color.argb(255,inR,inG,inB));

关于android - android java中的图像颜色校正,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14421427/

相关文章:

java - Android 以什么形式返回 EXIF GPS 数据?

php imagecopyresampled 质量差

css - Raphael.js 的彩色图像到灰度图像在 I.E. 中不起作用9

java - Color == Robot.getPixelColor 结果为 false,即使它们是相同的颜色?

javascript - 是否可以检测颜色是浅色还是深色?

android - 设置 3 个搜索栏以更改 RGB channel

android - 如何在 react-native 中使用 leaflet.js

java - EQ Solver 字符串返回中的复杂值问题

image - Matlab:根据引用位置用另一个矩阵替换一个矩阵中的值

iphone - CALayer 将无法工作