0

i am new in android programming. Now i am doing a color correction program using java for android platform.

In the program, i should be able to select a point on the bitmap and tell the program that it is actually white color, and the program will re-adjust all the pixels of that bitmap so that all the colors of that bitmap will be correct.

Can anyone tell me how can i do this? I am already able to retrieve a point from a bitmap now and calculate its RGB, but i got no idea how i can carry on. Please show me some examples or articles that i can read up on.

Thank you so much for your precious time. Hope to hear from you soon!


Resulting photo : http://www.flickr.com/photos/92325795@N02/8392038944/in/photostream

My photo is being updated and despite of the quality/noise/color, there are the weird colors here and there. Anyone have any idea what i should do to remove it? Or even better improve on the method i am using? Heres the code:

The input is the bitmap to edit, inColor is the color of the nose in the photo to be edited, reqcolor is the color of my nose in the sample/optimum photo.

    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;
 }

Thank you so much for help me! I cant express my gratitude further than saying another thank you in advance!

4

1 回答 1

1

阅读一些 白平衡算法。看看你能不能实现一些。另请注意,android 不提供用于大多数 java 教程的 awt.graphics / BufferedImage API。

Android 提供了ColorMatrixColorFilter用于此类用途,在此处讨论

操作像素的基本粗略方法:

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

    //--how much change ? --
    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);

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

        }
    }

    //-- all done--
    return input;
}
于 2013-01-14T11:33:22.453 回答