Java 高级成像缩放图像
我有一个 RenderedImage 形式的非常大的图像(~200,000x200,000 像素)。我裁剪了它,然后使用 JAI 的 ScaleDescriptor(它返回 RenderedOp)对其进行缩放。我的最终图像只有大约 30x30,但是当我从生成的缩放图像中调用 getAsBufferedImage
(我首先获得 PlanarImage
)时,需要几分钟的时间来创建。我猜想有一些参考原始图像需要很长时间,但我不确定。有谁知道为什么这会花这么长时间?
谢谢, 杰夫
I have a very large image (~200,000x200,000 pixels) in the form of a RenderedImage. I cropped it and then scaled it using JAI's ScaleDescriptor (which returns a RenderedOp). My final image is only about 30x30 but when I call getAsBufferedImage
(I get the PlanarImage
first) from the resulting scaled image, it takes several minutes to create. I'm guessing there is some reference back to the original image which is taking such a long time, but I'm not sure. Does anyone know why this would take so long?
thanks,
Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 JAI,您正在构建渲染链;因此,当您调用 .scale 时,它实际上并不会在此时进行缩放,而只是将其添加到链中(因此在调试器中它将是即时的)。只有在最后当您意识到新图像中的像素时,操作才会发生。
您正在进行的缩放量看起来很大,而且可能非常昂贵。我已经好几年没有做过JAI了;你能指定缩放算法吗?当你可以做一些更简单的事情时,它可能会进行不必要的插值。
With JAI you are building a rendering chain; so when you call .scale it does not actually scale at that point but just adds that to the chain (so in the debugger it will be instant). Only at the end when you go to realize the pixels in your new image does the operation happen.
The amount of scaling you are doing seems like a lot and is may be very expensive. I have not done JAI in a few years; can you specify the scaling algorithm? It might be doing unnecessary interpolation when you can get away with something much simpler.
尝试使用 http://www.imagemagick.org/script/index.php 你会看到更好的图像质量,
try with http://www.imagemagick.org/script/index.php you will see better picture quality,