Java:获取JPEG DCT系数直方图
我需要一个 Java 库、代码片段...来获取频率分布 JPEG 文件的 64 个 DCT 系数。
有什么想法吗?谢谢!
I need a Java library, code snippet,... to get the Frequency distribution of the
64 DCT coefficients of a JPEG file.
Any ideas? Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您对特定文件的分发感兴趣,那么您可以尝试将其转换为 bmp 并使用我的问题中提供的代码:
解压在中间停止并且输出文件用零填充(黑色像素)?
您可能需要弱化它才能与 java 一起使用。这个想法是将每个 8*8 块的所有 64 个系数存储在一个数组中。然后计算每个系数的每个值的频率,例如 0,0(DC) 或 0,1 或 8,8(最高频率),并在 y 轴上绘制频率,在 x 轴上绘制值。您将得到 64 个图,每个图对应一个系数。
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.
直接从 JPEG 文件中获取 DCT 系数似乎没有简单的答案。解压缩图像并重新应用 DCT 变换是一个合理的近似,但它确实容易引入舍入误差。
我发现直接从文件获取 JPEG 系数的唯一解决方案是使用 JNA 连接到本机 JPEG 库。您要求提供库或代码片段。我已经编写了一个 Java 库,应该可以满足您的需求。我的代码非常粗糙,但可以很容易地扩展。此处:https://github.com/markzampoglou/dct-extraction
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