非常大的图像处理和平铺
我需要一个 Java 语言的软件或程序,或者一种平铺超大图像(大于 140MB)的方法。 我使用过 ImageMagick 和转换工具 Photoshop、Corel Draw 和 Matlab(在 Windows 中),但我遇到了内存过载的问题。 ImageMagick 非常慢并且结果不理想。我不知道如何只将图像的一小部分加载到内存而不从硬盘加载整个图像。
I need a software or program in Java or a method for tiling very large images (bigger than 140MB).
I have used ImageMagick and convert tools Photoshop and Corel Draw and Matlab (in Windows), but I have a problem with memory overload. ImageMagick is very slow and result is not desirable. I don't know how can I only load a small part of image to memory without loading the whole image from harddisk.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用本机代码,libjeg 等库可以让您通过扫描线访问图像 - 您最多需要一次加载 16 条扫描线。
If you use native code, libraries such as libjeg give you scanline access to to images - you'd at most need to load 16 scanlines at a time.
您应该看看 Java Advanced Imaging (JAI) API,它为平铺大图像提供开箱即用的支持。这是一个有点复杂的 API,文档也有点稀疏,但我们在一个项目中使用它来查看每张大约 60 mb 的非常高(但很窄)的图像。
以下是一些可帮助您入门的链接:
使用 JAI 在 Java 中处理图像
JAI 项目主页
You should take a look at the Java Advanced Imaging (JAI) API, which provides out-of-the-box support for tiling large images. It's a somewhat complicated API and documentation is a tad sparse, but we've used it in a project for viewing very tall (but narrow) images that are around 60 mb a piece.
Here are a few links to get you started:
Process images in Java with JAI
JAI project homepage
它不是 Java,而是 Inter Performance Primitives (IPP) 具有一组可在图块上进行图像操作的函数。您或许可以通过 Java 连接这些函数。
It is not Java, but Inter Performance Primitives (IPP) have set of functions for image manipulation that work on tiles. You can probably interface these functions from Java.
JAI 依赖于平台,如今看起来像是一个死项目。
我建议使用开源程序imagemagick。尽管它依赖于平台,但它可用于与 JAI 相同的平台,但具有完整的社区支持。
关于 imagemagick 大图像的技巧是使用其“stream”命令而不是 < href="http://www.imagemagick.org/script/convert.php" rel="nofollow">转换 命令。 Stream仅读取图像的相关部分并将提取的部分保存为原始数据。然后,您需要“转换”将小原始数据保存为 jpeg。
将大小为 800x600 的大型.jpeg 从位置 0x0 保存到tile.jpeg 的示例:(
Windows 上运行时,请务必使用 ImageMagick 的 Convert.exe,因为有一个名为“convert”的 Windows 命令。)
在 仅限 TIFF 图像,apache Sanselan 可能是正确的选择 - 它是一个纯 java 成像库。此外,JAI 似乎包含一个独立于平台的 TIFF 编解码器。
JAI is platform dependent and seems like a dead project today.
I advise using the open-source program imagemagick. Although it is platform dependent, it is available for the same platforms as JAI, but with full community support.
The trick about large images about imagemagick is using its "stream"-command instead of the convert command. Stream only reads the relevant portion of the image and saves the extracted part as raw data. You then need "convert" to save the small raw data as jpeg.
Example to save a tile from large.jpeg of size 800x600 from position 0x0 to tile.jpeg:
(When running on windows, be sure to use ImageMagick's convert.exe, as there is a windows command named "convert".)
When working with TIFF-images only, apache Sanselan could be the right choice - it is a pure-java imaging lib. Also, JAI seems to contain a platform independent codec for TIFF.