|
Description
|
A DESCRIPTION OF THE REQUEST :
The lanczos interpolation algorithm seems on many (subjective) tests to give very customer results on both up but in particular downscaling - the results are both "smooth" (no jaggies) but "crisp" at the same time, w/o much artifacts (some ringing, but better than BICUBIC).
E.g.:
http://www.cambridgeincolour.com/tutorials/image-resize-for-web.htm
http://www.xs4all.nl/~bvdwolf/main/foto/down_sample/down_sample.htm
http://www.lassekolb.info/gim35_downsampling.htm
Google it.
IrfanView is a freeware program that have a bunch of these interpolation algorithms implemented, thus giving customer comparison.
It wouldn't hurt if there was a large selection, thus include Sinc and Mitchell while you're at it!
JUSTIFICATION :
Java only provides default two interpolation modes (hints), BILINEAR and BICUBIC. It would be great if one could get a couple of extra ones, more directly aiming for quality and not speed.
(Btw, BICUBIC's javadocs says that it uses 9 samples. All other explainations I've come by states 16. I thought that this "wasn't up for discussion" (its an algorithm that works so and such), so who's wrong?)
CUSTOMER SUBMITTED WORKAROUND :
Make a resizer oneself.
Posted Date : 2006-12-05 18:34:52.0
|
|
Comments
|
Submitted On 22-APR-2007
dgfsdfgdsfgsd
If you look at the bvdwolf link about, you'll see that the Lanczos filter is far superior in many contexts, especially downsizing. I am downsizing many images as part of a web application and have been using both ImageMagick (for batch conversions of existing images) as well as JDK (for conversion of uploaded images on the fly). I can tell you that the results from ImageMagick with the Lanczos filter blow away anything I can get out of the JDK, even after following the great advise in Chris Campbell's article "The Perils of Image.getScaledInstance() (whose title doesn't do it justice, btw, since it's got tons of value in terms of getting better quality reductions even out of drawImage(): http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
Submitted On 15-MAY-2007
+1, please add the Lanczos filter for image resampling. I agree it is a superior algorithm for quality vs. time and rids of the jaggies, by producing a smooth picture. Please add this one! Thanks!
Submitted On 27-JUN-2007
stolsvik
Actually, (heavy) _downsizing_ in java is _always_ terrible, and wouldn't necessarily become better by using Lanczos or any other.
The problem is that when downsizing, the algorithms apparently just "sample" a constant set of pixels from the source image per destination pixel, thus not using all pixels in the original. This is so fantastically flawed that I don't quite get why they allow downsizing at all with this approach!
It is essential to downsize by factors of 2 until "in the vicinity" of the actual size (last downsize step above), then use e.g. the bicubic, as Chris Campbell suggest. Why doesn't java do this by itself, one wonders? Think of all the people that just "use the default", assuming that some bright minds have done the right thing.. "Ugly-java" is the net result.
However, even the 2x downscaling approach will not yield the best possible result: the initial lanczos sample-box should be made large enough based on the initial image's size, so that all pixels were used in the first round. Or, for the linear or bicubic algos, they should take into account all the source pixels that each destination pixel encompass, for example by averaging them before doing the interpolation, or put some math-genius on it that knows this stuff properly!
It is sad that Irfanview have such much better downscaling than possible with the built-in java operators - and we're on java *6* in the year 2007!
The interpolation hints are pretty much aimed at upscaling - in this scenario they do give sane result. But Lanczos is just so much better.
Here's wikipedia link:
http://en.wikipedia.org/wiki/Lanczos_resampling
Submitted On 07-AUG-2007
Please add Lanczos filter for image resizing (esp. downsizing). The current bilinear and bicubic provide very poor quality and don't give many alternatives in Java. Thus, I often have to resort using programs like IrfanView. However, when building Java applications we're stuck with poor image resize quality. Any idea when Lanczos RenderHint will be put in? Thanks.
Submitted On 07-JUL-2009
prunge
This library can do Lancoz3 filtering as well as others:
http://code.google.com/p/java-image-scaling/
More info here:
http://www.nobel-joergensen.com/roller/java/entry/downscaling_images_in_java
Works with buffered images. I found it very useful.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|