[英]Adding 2 Images with Android Renderscript
I am trying to increase exposure time of my camera by adding the values of 2 back to back capture. 我试图通过增加2背对背拍摄的值来增加相机的曝光时间。 It took far too long to calculate with Java so I decided to attempt Renderscript.
使用Java进行计算花了太长时间,因此我决定尝试使用Renderscript。 I seem to have all of the bugs worked out but the end result has some pretty weird effects
我似乎已经解决了所有错误,但最终结果产生了一些非常奇怪的效果
Most of the chair and floor in this image are fine but areas get mostly bright green and blue discolouration. 此图像中的大多数椅子和地板都很好,但大部分区域会出现鲜绿色和蓝色变色。
Here is the Renderscript file: 这是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;
}
And here is the Java code that executes the Renderscript: 这是执行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);
I couldn't find anything in the logs that appeared to be a warning/error. 我在日志中找不到任何似乎是警告/错误的内容。 Any ideas of how this can be solved?
关于如何解决的任何想法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.