Java - I need a very fast image scaling algorithm

删除回忆录丶 提交于 2019-11-27 14:16:40

问题


I am working on a Midlet application. I am finding myself in the need to scale images very often. This has become a problem because some phones are pretty slow and scaling takes too long.

Currently I'm using Image.createRGBImage(int, int, int, boolean) to scale the image.

I was wondering if any of you knew of a very efficient and fast way to scale an image.

Note: this is a Midlet application so only JavaME is available, meaning I don't have access to some other libraries available in the full java version.

Note2: most of my scaling is done from small to large images, although I also do scale down the image.


回答1:


Keep in mind that there's always a trade between speed and image quality when discussing scaling algorithms, and the ideal solution for your case might require some research and testing.

Nearest neighbor is the simplest and fastest implementation of image scaling.

There's a nice intro on image scale/resize on Coding Horror which reviews a couple of techniques and compares their quality.

I imagine you are working with a very small displaying device, so image quality doesn't really matter at the end. Some people are calling this the fastest image scaling implementation for J2ME.

But if you are willing to read some other stuff, this paper presents a low cost (meaning "very fast") algorithm for scaling that significantly improves on nearest neighbor interpolation. There's source code available, and they also present an evolution of that research here.

At last but not least, cvResize() from OpenCV (open source/cross-platform library for image processing). The folks at willow garage are pretty good at making fast procedures for image/video processing, and this function provides a couple of techniques for scaling, so it might be worth to check it's implementation.



来源:https://stackoverflow.com/questions/8244936/java-i-need-a-very-fast-image-scaling-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!