JAI:读取 12 位 JPEG 文件

发布于 2024-09-13 01:11:34 字数 270 浏览 7 评论 0原文

我是 Java 高级成像领域的新手,我遇到的第一个障碍是读取 12 位、单波段、灰度 JPEG 文件的能力。我已经看到有关 JAI 可以实现这一点的参考,但没有代码,甚至没有关于如何完成它的建议。有人可以通过有用的链接或简短的代码片段帮助我吗?

到目前为止,我一直在使用本教程,但没有帮助我在这个问题上。

谢谢。

I'm brand new to Java Advanced Imaging, and the first stumbling block I've reached is the ability to read in a 12 bit, single band, greyscale JPEG file. I've seen references to it being possible with JAI, but no code or even suggestions about how it should be done. Could someone please help me out with either a helpful link or a short code snippet?

I've been using this tutorial so far, but it hasn't helped me on this issue.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪菊怪哟 2024-09-20 01:11:34

JAI-ImageIO 会将自身注册到 Java 的 ImageIO api 中,因此您只需将 jai-imageio jar 放在类路径中并调用普通 ImageIO 方法(例如 ImageIO.read(file))就可以使用它。

jpeg 的问题可能是 Java 在 IIORegistry 中有一个默认的 jpeg 读取器,您可能必须使用 ImageIO.getImageReadersForFormatName() 之类的方法手动选择正确的读取器。

更深奥的格式的另一件事是 JAI ImageIO 通常有两种实现 - 一种是纯 Java,另一种使用本机二进制库,因此请确保在LD_LiBRARY_PATH 或位于程序的工作目录中。本机实现通常支持比纯 java 模式格式变体。

JAI-ImageIO will register itself into Java's ImageIO api, so you should be able to use it just by having the jai-imageio jars in your classpath an calling the normal ImageIO methods, such as ImageIO.read(file).

The problem with jpeg might be that Java has a default jpeg reader in the IIORegistry, and you may have to select the right one manually using something like ImageIO.getImageReadersForFormatName().

Another thing with the more esoteric formats is that JAI ImageIO usually has two implementations - one pure Java and the other using native binary libraries, so make sure that you include the *lib-wrapper.dll (or whatever suits your particular OS) in the LD_LiBRARY_PATH or have the in the working directory of your program. The native implementation usually supports mode format variants than the pure-java one.

偏闹i 2024-09-20 01:11:34

我们通常使用 JAI + JAI Image I/O 读取 JPEG 12 位灰度图像。

除了之前的答案之外,您还需要本机二进制库来读取 JPEG 12 位,因此需要 mediaLib 库。

您只需要从图像 I/O 进行“ImageRead”操作:

byte[] imageBytes = ...
RenderedOp readImage = JAI.create("ImageRead", new MemoryImageInputStream(imageBytes));

通常从 FTP 读取图像文件,因此获取 byte[] 并需要包装的自定义 MemoryImageInputStream通过子类化 ImageInputStreamImplbyte[] 转换为 ImageInputStream

we usually read JPEG 12bit grayscale images using JAI + JAI Image I/O.

Additionally to previous answers, you need the native binary libraries to read JPEG 12bit, so mediaLib library is required.

You only need the "ImageRead" operation from Image I/O:

byte[] imageBytes = ...
RenderedOp readImage = JAI.create("ImageRead", new MemoryImageInputStream(imageBytes));

Whe usually read the image files from FTP, so get the byte[] and need the custom MemoryImageInputStream that wraps a byte[] into a ImageInputStream by subclassing ImageInputStreamImpl.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文