我试图通过添加2个背对背捕捉的值来增加相机的曝光时间。使用Java计算花了太长时间,所以我决定尝试使用Renderscript。我似乎已经解决了所有错误,但最终结果有一些非常奇怪的效果
此图片中的大部分椅子和地板都很好,但区域大部分都是明亮的绿色和蓝色变色。
这是Renderscript文件:
#pragma version(1)
#pragma rs java_package_name(edu.marquette.mcw.smartme)
rs_allocation extra_alloc;
uchar4 __attribute__((kernel)) combine(uchar4 a, uint32_t x, uint32_t y)
{
// get second image
uchar4 b = rsGetElementAt_uchar4(extra_alloc, x, y);
// combine red value
uint32_t red = a.r + b.r;
//set to max value if it exceeds it
if(255 - a.r < b.r)
{
red = 255;
}
a.r = red;
// combine green value
uint32_t green = a.g + b.g;
if(255 - a.g < b.g)
{
green = 255;
}
a.g = green;
// combine blue value
uint32_t blue = a.b + b.b;
if(255 - a.b < b.b)
{
blue = 255;
}
a.b = blue;
// return result
return a;
}
这是执行Renderscript的Java代码:
// Load Script
RenderScript RS = RenderScript.create(callingFrag.getActivity());
ScriptC_combine script = new ScriptC_combine(RS);
output = Bitmap.createBitmap(combined.getWidth(), combined.getHeight(), combined.getConfig());
// Send in bitmaps
Allocation aAllocation = Allocation.createFromBitmap(RS, combined);
Allocation bAllocation = Allocation.createFromBitmap(RS, exposures.remove(0));
Allocation outputAllocation = Allocation.createFromBitmap(RS, output);
script.set_extra_alloc(bAllocation);
// Run Script
script.forEach_combine(aAllocation, outputAllocation);
App.log("Combine Time: " + (System.currentTimeMillis() - start));
outputAllocation.copyTo(output);
我在日志中找不到任何似乎是警告/错误的内容。关于如何解决这个问题的任何想法?
答案 0 :(得分:0)