문제

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

도움이 되었습니까?

해결책

Ultimately the DCT calculation is just one step in the whole JPEG encoding process. A complete implementation also has to deal with quantization, Huffman encoding, and conforming with the JPEG standard.

Java effectively just gives you an interface to a JPEG encoder that lets you do useful things like save images.

The ImageWriter that ImageIO.write() uses for JPEG images depends on your system. The default ImageWriter for JPEGs will only let you change some settings that affect the quantization and encoding using the JPEGImageWriteParam class (http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageWriteParam.html).

Getting your hand-crafted DCT coefficients into a JPEG file could potentially involve writing an entire JPEG library. If you don't want to do all that work, then you could modify the source of an existing library so that it uses your DCT coefficients.

다른 팁

Before the DCT . . .

While JPEG has no knowledge of colors, it is normal for JPEG file formats to use the YCbCr color space. If you are thinking about writing a JPEG file, you would need to do this conversion first.

After the Quantization . . .

The coefficients are run length encoded. That's a step you'd have to add. That's the most complex part of JPEG encoding.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top