- Image quality, scaling algorithm and parameters -


JImageFilter properties under scaling.properties allow to define scaling algorithm and others parameters that affect scaling quality and speed. If you're a photographer or a printing company who plans to print scaled images then you may need quality first. If you're a webmaster who plans to scale a lot of images into small thumbnails then you may need speed first.

Scaling quality

Scaled image quality depends on incoming image dimensions, scaling algorithm and "quality" parameter for JPEG format. JImageFilter supports four scaling algorithms. The table below sums up the differences between each:

Scaling algorithm Image quality Scaling speed Memory usage
ImageIO subsample Low Very fast Very low
ImageIO on-step bicubic Good Fast Low
ImageIO multi-step bilinear Better Medium Medium
AWT Best Slow Low

Default scaling.properties is setup with ImageIO on-step bicubic because it provides the best quality/speed ratio. However, if you need quality first then you should use AWT implementation (i.e. uncomment impl=awt in scaling.properties). Even if twice slower, it is the recommended one when scaling large images.

Sample1: Reduce image dimensions by around 4.
Here is a sample below of a scaled image. Original image (1132x1696, 2139 KB, RGB 24bits) was scaled into 320x480. Notice how "SHERIFF" edges are differents between ImageIO bicubic to the two others. Multi-step bilinear and AWT are quite similar.

Algorithm: ImageIO on-step bicubic
   impl=ImageIO
Time to scale: 1.6 seconds
Scaled size: 27 KB
Default quality parameter (0.75).

Algorithm: ImageIO multi-step bilinear
  impl=ImageIO
  multistep=true
Time to scale: 1.9 seconds
Scaled size: 22 KB
Default quality parameter (0.75).

Algorithm: AWT
   impl=awt
Time to scale: 3.1 seconds
Scaled size: 21 KB
Default quality parameter (0.75).

Sample2: Reduce image dimensions by around 9.
Here is a sample below of a scaled image with an important moiré pattern. Original image (2718x4077, 3551 KB, RGB 24bits) was scaled into 320x480.

Algorithm: ImageIO on-step bicubic
   impl=ImageIO
Time to scale: 6.1 seconds
Scaled size: 37KB
Default quality parameter (0.75).

Algorithm: ImageIO multi-step bilinear
  impl=ImageIO
  multistep=true
Time to scale: 8.4 seconds
Scaled size: 25KB
Default quality parameter (0.75).

Algorithm: AWT
   impl=awt
Time to scale: 12.1 seconds
Scaled size: 25KB
Default quality parameter (0.75).

Note: Performance tests have been done with an old computer configuration (JRE 1.5, Windows 2000, One CPU 1GHz). It should be quite faster on a recent box.

JPEG Quality parameter

"quality" parameter in scaling.properties affects the JPEG compression after scaling. It's a range from 0.0 to 1.0. For instance, 0.1 means best compression and then poor quality. 0.9 means low compression and best quality. Notice the squares appearing when quality is low on the sample 1 below:

Algorithm: AWT
   impl=awt
Scaled size: 7 KB
Quality: Very low
   quality=0.1

Algorithm: AWT
   impl=awt
Scaled size: 21 KB
Quality: Default
   quality=0.75

Algorithm: AWT
   impl=awt
Scaled size: 36 KB
Quality: Very high
   quality=0.9

In conclusion, using default quality should fit to most users including photographers and printing companies.

 

 

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
All other company and/or product names are the property of their respective owners.