views:

292

answers:

3

I have some JPEG images that I need scale down to about 80% of original size. Original image dimension are about 700px × 1000px. Images contain some computer generated text and possibly some graphics (similar to what you would find in corporate word documents).

How to scale image so that the text is as legible as possible? Currently we are scaling the imaeg down using bicubic interpolation, but that makes the text blurry and foggy.

+2  A: 

If you are not set on exactly 80% you can try getting and building djpeg from http://www.ijg.org/ as it can decompress your jpeg to 6/8ths (75%) or 7/8ths (87.5%) size and the text quality will still be pretty good:

Original

7/8

3/4

(SO decided to scale the images when showing them inline)

There may be a scaling algorithm out there that works similarly, but this is an easy off the shelf solution.

Dolphin
+1  A: 

Two options:

  1. Use a different resampling algorithm. Lanczos gives you a much less blurrier result.

  2. You ight use an advances JPEG library that resamples the 8x8 blocks to 6x6 pixels.

Ritsaert Hornstra
I'll look into Lanczos. Do you have any idea how performance intensive it is compared to bicubic?
Juha Syrjälä
Yes, You need up to 25 samples instead of 4 so it is more expensive, but since you have a fixed resize, you could precanlculate the weight of the samples in advance for all different subpositions and it should be as compute intensve as say JPEG decode.
Ritsaert Hornstra
+1  A: 

There is always a loss involved in scaling down, but it again depends of your trade offs.

  1. Blurring and artifact generation is normal for jpeg images, so its recommended that you generate images is the correct size the first time.
  2. Lanczos is a fine solution, but you have your trade offs
  3. If its just the text and you are concerned about it, you could try dilation filter over the resampled image. This would correct some blurriness but may also affects the graphics. If you can live with it, its good. Alternatively if you can identify the areas of text, you can apply dilation just over those areas.
the100rabh