Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在YUV颜色空间中操纵luma_Android_Image Processing_Yuv - Fatal编程技术网

Android 在YUV颜色空间中操纵luma

Android 在YUV颜色空间中操纵luma,android,image-processing,yuv,Android,Image Processing,Yuv,我习惯于在格式为字节[]的图像上设置对比度/亮度。 图像位于YCbCr_420颜色空间(android摄像头)。 我通过以下方式获取luma值: for (int j = 0, yp = 0; j < height; j++) { for (int i = 0; i < width; i++, yp++) { int y = (0xff & (yuv420sp[yp])) - 16; } } Thanx的任何帮助。我从这个API知道的一点是,3个通道的值被连

我习惯于在格式为字节[]的图像上设置对比度/亮度。 图像位于YCbCr_420颜色空间(android摄像头)。 我通过以下方式获取luma值:

for (int j = 0, yp = 0; j < height; j++) {
for (int i = 0; i < width; i++, yp++) {
    int y = (0xff & (yuv420sp[yp])) - 16;
    }
}

Thanx的任何帮助。

我从这个API知道的一点是,3个通道的值被连接在一个字节数组中。同样,在使用RGB的Windows中,我想这里也有相同的,我的意思是,每3个字节代表一个像素。所以我想,你可以每3个位置跳一次,只访问一个通道(在你的例子中是Luma)。我只是不知道luma是由第一个、第二个还是第三个字节表示

第二,如果我知道你只想改变亮度/对比度(增加/减少),对吗? 因为如果是这样,对比度就是乘法,亮度就是加法

例如-假设您使用的是8位通道的伪代码:

luma[y] = luma[y] * 1.10; //Increases contrast
或者您可以使用更通用的形式:

luma[y] = luma[y] + (luma[y] * contrast); //where contrast ranges from -1.0 to 1.0
同样,您也可以对亮度执行相同的操作:

luma[y] = luma[y] + bright; //Where bright can range from -255 to 255

在这两种情况下,在将最终像素结果分配给图像之前,您必须小心溢出和下溢。

此示例应用程序的APLEAGLView.m文件中最好地演示了YUV处理:

在Shader.fsh文件中演示了对亮度和对比度的适当调整,以使它们保持彼此成比例的关系:

如果你需要解释代码的帮助,我可以帮你。但目前,使用用户指定的亮度阈值,亮度调整后的Y平面的计算如下:


Y'=(Y-(16/255))*lumaThreshold

thanx Andres了解亮度/对比度信息。获取y值的方法工作正常,设置y的方法正确吗(需要掩码吗?):yuv420sp[yp]=(字节)((0xff&y)+16);您好,这部分代码:yuv420sp[yp]=(字节)((0xff&y)+16)是错误的(图像是绿色的),请问,有人能建议如何正确设置YUV中的值吗?对于对比度,乘以1.10这样的因子会使所有东西都变亮,而您需要的是使明亮的东西变亮,使黑暗的东西变暗。相反,我会乘离中心值:如果值为0到255,则使用
luma[y]=(luma[y]-128)*1.10+128
luma[y] = luma[y] + bright; //Where bright can range from -255 to 255