处理 150GB .jp2 图像
我下载了一个 150GB 的卫星 .jp2 图像,我一次只想要其中的一小部分。 我将如何将图像平铺为可管理的块?只需提取图像的一部分就足够了。
由于我对 Python 只是有点熟悉,所以我查看了 Pillow 和 OpenCV 库,但由于图像分辨率超出了它们的限制而没有成功。 我还研究了 Openslide for Python,但无法消除错误(无法找到模块“libopenslide-0.dll”)。
I downloaded a 150GB satellite .jp2 image, of which I only want a small section at a time.
How would I go about tiling the image in manageable chunks? Just extracting a part of the image would also be enough.
As I'm only somewhat familiar with Python, I looked at the Pillow and OpenCV libraries, but without success as the image resolution exceeds their limits.
I also looked into Openslide for Python, but couldn't get rid of an error (Could not find module 'libopenslide-0.dll').
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
libvips 可以高效处理大图片。
例如,对于这个 2.8gb 测试图像:
我明白了:
因此,它在 0.5 秒内从 110,000 x 80,000 像素 jp2 图像中取出 1,000 x 1,000 像素块,并且需要不到 200mb 的内存。
有 python、ruby、node 等的绑定,因此您不必使用 CLI。
在 python 中你可以这样写:
它确实有点依赖于你正在读取的 jp2 图像。有些是直到(!!)并且读出一个部分可能非常慢。
也有 Windows 二进制文件,请查看“下载”页面。
如果您使用的是 Linux,vipsdisp 可以非常快速地查看像这样的巨大图像。
libvips can process huge images efficiently.
For example, with this 2.8gb test image:
I see:
So it takes a 1,000 x 1,000 pixel chunk out of a 110,000 x 80,000 pixel jp2 image in 0.5s and needs under 200mb of memory.
There are bindings for python, ruby, node, etc., so you don't have to use the CLI.
In python you could write:
It does depend a bit on the jp2 image you are reading. Some are untiled (!!) and it can be very slow to read out a section.
There are windows binaries as well, check the "download" page.
If you're on linux, vipsdisp can view huge images like this very quickly.
Grok JPEG 2000 工具包
能够解压缩极大图像的区域,例如
您链接到的 150 GB 图像。
示例命令:
grk_decompress -i FOO.jp2 -o FOO.tif -d 10000,10000,15000,15000 -v
解压缩区域
(10000,10000,15000,15000)
代码> 为 TIFF 格式。Grok JPEG 2000 toolkit
is able to decompress regions of extremely large images such as
the 150 GB image you linked to.
Sample command:
grk_decompress -i FOO.jp2 -o FOO.tif -d 10000,10000,15000,15000 -v
to decompress the region
(10000,10000,15000,15000)
to TIFF format.