1
我正在创建图像压缩程序,我想将颜色从RBG转换为YCbCr,我没有问题将图像提取到像素并从每个像素获取RBG信息,但是,我不知道如何用新的YCbCr信息打包像素以产生新图像。将颜色从RGB转换为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拥有更多的信息,但我的想法如何包装在一起,也许任何人都可以帮助我?
你见过这个吗? http://stackoverflow.com/questions/6311460/rgb-to-ycbcr-conversion-in-matlab或http://en.wikipedia.org/wiki/YCbCr还有一个:) http://www.equasys。德/ colorconversion.html –