繁体   English   中英

将颜色从RGB转换为YCbCr包装图像

[英]Converting colors from RGB to YCbCr packing image

我正在创建图像压缩程序,我想将颜色从RBG转换为YCbCr,我没有问题将图像提取为像素并从每个像素获取RBG信息,但是,我不知道如何将像素与新的YCbCr信息打包在一起以产生新图片。

我编写了处理RGB信息并将其放回原处的代码,如下所示:

private static int packPixel(int red, int green, int blue) {
   return (red << 16) | (green << 8) | blue;
}

public BufferedImage makeNewBufferedImage(short[][] ImageDataRed, short[][] ImageDataGreen, short[][] ImageDataBlue ) {
   int[] newBufferedImageData = new int[rows * cols];
   int index;
   for (int row = 0; row < rows; row++) {
       for (int col = 0; col < cols; col++) {
           index = (row * cols) + col;
           newBufferedImageData[index] = packPixel(ImageDataRed[row][col], ImageDataGreen[row][col], ImageDataBlue[row][col]);
       }
   }

我知道YCbCr拥有更多信息,但是我不知道如何将其打包在一起,也许有人可以帮助我吗?

Java Advanced Imaging似乎支持YCbCr。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM