1

I am using the BufferedImage class to read in an image as pixels which I then use bit shifting to get their appropriate components into separate int arrays. This works OK.

I have used this reference site to manually perform DCT functions with the pixel arrays.

Methods used: forwardDCT(), quantitizeMatrix(), dequantitzeMatrax(), inverseDCT()

which then are fed back into a resultant image array to reconstruct the JPEG file, which I then use BufferedImage's write() method to write the pixel data back out as the image.

This works perfectly, and I can view the image. (Even better the value I use to compress visually works).

My question is, is there a way to write the quantitize coefficients as the compressed values as a JPEG?

Because the BufferedImage write() method is used to input pixel data, rather than coefficient data?

Hope this is clear.

Thanks

4

2 回答 2

2

最终,DCT 计算只是整个 JPEG 编码过程中的一个步骤。一个完整的实现还必须处理量化、霍夫曼编码和符合 JPEG 标准。

Java 实际上只是为您提供了一个 JPEG 编码器的接口,让您可以做一些有用的事情,例如保存图像。

ImageIO.write() 用于 JPEG 图像的 ImageWriter 取决于您的系统。JPEG 的默认 ImageWriter 仅允许您使用 JPEGImageWriteParam 类 ( http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageWriteParam.html )更改一些影响量化和编码的设置。

将您手工制作的 DCT 系数放入 JPEG 文件可能涉及编写整个 JPEG 库。如果您不想做所有这些工作,那么您可以修改现有库的源代码,以便它使用您的 DCT 系数。

于 2014-03-22T04:52:12.127 回答
1

在 DCT 之前。. .

虽然 JPEG 不了解颜色,但 JPEG 文件格式使用 YCbCr 颜色空间是正常的。如果您正在考虑编写 JPEG 文件,则需要先进行此转换。

量化后。. .

系数是游程编码的。这是您必须添加的步骤。这是 JPEG 编码中最复杂的部分。

于 2014-03-22T04:46:31.593 回答