概述
byte[] rgb888_2_nv21(byte[] src, int width, int height) {
byte[] iYuv = new byte[3*width * height/2];
int ui = width * height;
int i = 0;
int j, k;
int sR,sG,sB;
for (j = 0; j < height; j++) {
for (k = 0; k < width; k++) {
int index = 3*(j*width+k);
sR = Byte.toUnsignedInt(src[index]);
sG = Byte.toUnsignedInt(src[index+1]);
sB = Byte.toUnsignedInt(src[index+2]);
int temp = ((299 * sR + 597 * sG + 114 * sB) / 1000);
if(temp>254){
temp = 254;
}
iYuv[i] = (byte) temp;
if (0 == j % 2 && 0 == k % 2) {
iYuv[ui] = (byte)((500*sR - 418.7 * sG - 81.3*sB+128000)/1000);
ui++;
iYuv[ui] = (byte)((-168.7 * sR - 331.3 * sG + 500*sB +128000)/1000);
ui++;
}
i++;
}
}
return iYuv;
}
byte[] ir_2_nv21(byte[] src, int width, int height) {
byte[] iYuv = new byte[3*width * height/2];
int ui = width * height;
int i = 0;
int j, k;
int sR,sG,sB;
for (j = 0; j < height; j++) {
for (k = 0; k < width; k++) {
int index = (j*width+k);
sR = Byte.toUnsignedInt(src[index]);
int temp = sR;
if(temp>254){
temp = 254;
}
iYuv[i] = (byte) temp;
if (0 == j % 2 && 0 == k % 2) {
iYuv[ui] = (byte) 128;
ui++;
iYuv[ui] = (byte) 128;
ui++;
}
i++;
}
}
return iYuv;
}
最后
以上就是搞怪月饼为你收集整理的java rgb888转yuv nv21 红外图转yuv nv21的全部内容,希望文章能够帮你解决java rgb888转yuv nv21 红外图转yuv nv21所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复