1

画像の魔女のコントラスト/明るさをバイト[]の形式で設定することはありません。画像は YCbCr_420 色空間 (Android カメラ) です。この方法で輝度値を取得しています:

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

より多くの光を設定するためにy値を操作する方法は? これが値を元に戻すための直感的な方法であるかどうかもわかりません。

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

助けてくれてありがとう。

4

2 に答える 2

2

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.

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.

于 2012-05-21T11:44:15.140 に答える