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 –