Java: Getting JPEG DCT coefficients histogram
I need a Java library, code snippet,... to get the Frequency distribution of the 64 DCT coefficients of a JPEG file.
Any idea开发者_Python百科s? Thx!
If you are interested in the distribution of a particular file then you can try to convert it into bmp and use my code provided in my question:
Decompression stops inbetween and output file filled with zeros(BLACK PIXELS)?
You may need to weak it to work with java. The idea is store all 64 coeff in an array for each 8*8 block. Then count the frequency of each value for each coeff no such as 0,0(DC) or 0,1 or 8,8(highest freq) and plot the frequency in y-axis and value in x-axis. you will get 64 plots, one for each coefficient.
It seems that there is no simple answer to directly getting the DCT coefficients from a JPEG file. Decompressing the image and re-applying the DCT transform is a reasonable approximation, but it does tend to introduce rounding errors.
The only solution I found to getting the JPEG coefficients directly from the file was to use JNA to connect to the native JPEG library. You asked for a library or code snippet. I have written a Java library that should meet your needs. My code is very crude but can be easily extended. Here: https://github.com/markzampoglou/dct-extraction
精彩评论