我是android程序的新手。现在我正在为android平台做一个使用java的颜色校正程序。
在程序中,我应该能够选择位图上的一个点,告诉程序它实际上是白色的,程序将重新调整该位图的所有像素,以便该位图的所有颜色都是正确的。
有人能告诉我怎么做吗?我现在已经能够从位图中检索一个点并计算它的RGB,但我不知道如何继续下去。请给我看一些我可以阅读的例子或文章。
非常感谢你宝贵的时间。希望不久能收到你的来信!
结果图片:http://www.flickr.com/photos/92325795@N02/8392038944/in/photostream
我的照片正在更新,尽管质量/噪音/颜色,有奇怪的颜色在这里和那里。有人知道我该怎么做才能把它移除吗?或者更好地改进我正在使用的方法?这是代码:
输入是要编辑的位图,inColor是要编辑的照片中鼻子的颜色,reqcolor是示例/最佳照片中我的鼻子的颜色。
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;
}非常感谢你帮我!我不能更多地表达我的感激之情,只能提前说一句谢谢你!
发布于 2013-01-14 11:33:22
阅读一些白平衡算法。看看你能不能实现一些。还请注意,android没有提供awt.graphics / BufferedImage API,这在大多数java教程中都有使用。
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;
}https://stackoverflow.com/questions/14317383
复制相似问题