本文介绍了在YUV色彩空间操纵亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不会设定对比度/ brightnes图像女巫在形式上的byte []。该图像是在YCbCr_420色彩空间(Android摄像头)。我是歌厅的亮度值是这样的:

I wont to set contrast / brightnes on image witch is in form byte[].The image is in YCbCr_420 color space (android camera).I am geting luma value this way :

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

如何操作的y值设置更多的光?我也不知道这是直觉的方式来重新设置的值:

How to manipulate y value to set more light?I am also not sure if this is gut way to set back the value :

yuv420sp[yp] = (byte) ((0xff & y) +16);

感谢名单的任何帮助。

Thanx for any help.

推荐答案

小,我知道这个API是为3个通道的值连接起来的一个字节数组。因此,同样在Windows正在与RGB,我想在这里你有一样的,我的意思是,每3个字节重新presenting一个像素。所以我想,你可以访问它跳跃的每3个职位为仅访问一个单声道(亮度你的情况)。我只是不知道,如果亮度被重新由第一,第二或第三个字节psented $ P $。

The little that I know from this API is that the values for the 3 channels are concatenated in a byte array. So, likewise in Windows working with RGB, I guess here you have the same, I mean, every 3 bytes representing one pixel. So I GUESS, you could access it jumping every 3 positions to access only one single channel (Luma in your case). I just don't know if the luma is represented by the first, second or third byte.

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

Second, if I understand you just want to change bright/contrast (increase/decrease) is that correct?Because if so, contrast is just multiplication and brightness is addition.

例如 - 伪code假设你正在使用8位通道:

For instance - pseudo code assuming you are working with 8bits channel:

luma[y] = luma[y] * 1.10; //Increases contrast

或者你可以有一个更通用的形式:

or you can have a more generic form:

luma[y] = luma[y] + (luma[y] * contrast); //where contrast ranges from -1.0 to 1.0

同样可以用亮度做同样的:

Similarly you can do the same with brightness:

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

在这两种情况下,你有你的最终像素的结果分配给您的图片前,要小心溢出和下溢。

In both cases you have to be careful with overflows and underflows before you assign the final pixel result to your image.

这篇关于在YUV色彩空间操纵亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 02:44