我正在开发 Midlet 应用程序。我发现自己经常需要缩放图像。这已经成为一个问题,因为有些手机速度非常慢并且缩放需要很长时间。
目前我正在使用 Image.createRGBImage(int, int, int, boolean) 来缩放图像。
我想知道你们中是否有人知道一种非常有效且快速的缩放图像的方法。
注意:这是一个 Midlet 应用程序,因此只有 JavaME 可用,这意味着我无法访问完整 java 版本中可用的其他一些库。
注2:我的大部分缩放都是从小图像到大图像完成的,尽管我也会缩小图像。
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)
请记住,在讨论缩放算法时速度和图像质量之间总是存在权衡,并且适合您的情况的理想解决方案可能需要一些研究和测试。
最近邻居是最简单、最快图像缩放的实现。
Coding Horror 它回顾了几种技术并比较了它们的质量。
我想您正在使用一个非常小的显示设备,因此图像质量最终并不重要。有些人正在调用 此 最快的J2ME图像缩放实现。
但如果您愿意阅读其他内容,本文提出了一种低成本(意味着“非常快”)的缩放算法,可显着改进最近邻插值。有可用的源代码,他们还介绍了该研究的演变此处。
最后但并非最不重要的一点是,
cvResize()
来自 OpenCV(用于图像处理的开源/跨平台库)。 willow Garage 的人员非常擅长制作图像/视频处理的快速程序,并且此函数提供了一些缩放技术,因此可能值得检查它的实现。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.