Page 1 of 1

Summary: reducing (downsizing) natural images

Posted: 2012-08-10T07:38:26-07:00
by NicolasRobidoux
Here is my overall take on viewtopic.php?f=1&t=20992 and some other threads (discussions tend to bleed between related topics). This is still evolving but I am fairly confident that what follows will survive additional investigation.
The following is most pertinent to the common sRGB to sRGB natural image reduction (or thumbnail production) but the main ideas should apply in general. This is probably is a good guide for synthetic (CG) images as well, but less testing has been done with those. Transparency channels may also complicate matters.

FOR BEST QUALITY
Rule 1. Always go through linear light (RGB colourspace in ImageMagick): http://www.imagemagick.org/Usage/resize ... colorspace.
Heed the warning RE: older versions than IM6.7.5.
Rule 2. At equivalent sharpness/faithfulness, EWA (-distort resize) filters give better results (less moire, jaggies and halo) than orthogonal (-resize) filters.
Rule 3. Unless you are really averse to haloing, use the EWA Lanczos 3,4,5 family of Jinc-windowed Jinc filters. (LanczosSharp, LanczosRadiusN and LanczosSharpest are members of this family.) That is, choose
  • LOBES among 3,4,5 (maybe 2 if you really dislike haloing, in which case you probably should consider EWA Mitchell, Robidoux, Quadratic or Triangle instead of EWA Lanczos),
  • BLUR between .7 and 1.0 (values between .88 to .95 generally work well),
  • SIZE according to the syntax given in http://www.imagemagick.org/Usage/resize/#resize, for example WIDTHxHEIGHT,
and run

Code: Select all

convert INPUT.IMG -colorspace RGB -filter Lanczos -define filter:lobes=LOBES -define filter:blur=BLUR -distort Resize SIZE -colorspace sRGB OUTPUT.IMG
A larger value of LOBES decreases moire (good) and jaggies (good), and increases halo (bad) and perceived sharpness (good).
A smaller value of BLUR increases sharpness (good), moire (bad) and jaggies (bad).
When downsampling (downsizing), the exact value of BLUR appears to matter less than when upsampling (enlarging). For specific suggestions, see the aforementioned thread.
Rule 4. With well chosen parameters (which depend on content and personal preferences), you should not need to apply unsharp masking (USM) afterward, and things should look more natural than if you rely on USM to keep things sharp. At least, you should not have to USM as much to regain sharpness.
Disclaimer: What precedes is my personal opinion, and does not necessarily represent the opinions of others, including ImageMagick developers. Everyone is of course welcome to comment below.

Note: There are shortcuts to some of the suggested parameter values. The above is meant to be tweakable, not concise.

Re: Summary: reducing (downsizing) natural images

Posted: 2012-08-10T09:39:22-07:00
by henrywho
Are "LanczosRadiusN" and "LanczosSharpestN" available directly in IM6 or 7 now?

Re: Summary: reducing (downsizing) natural images

Posted: 2012-08-10T09:42:01-07:00
by NicolasRobidoux
henrywho wrote:Are "LanczosRadiusN" and "LanczosSharpestN" available directly in IM6 or 7 now?
No.

Re: Summary: reducing (downsizing) natural images

Posted: 2012-08-10T09:49:03-07:00
by henrywho
A small note that some ppls like to take BW (gray) photos but IM6 behaves weirdly with gray photos and -colorspace options. Better use -gamma with gray photos for the time being.

Re: Summary: reducing (downsizing) natural images

Posted: 2012-08-10T10:18:21-07:00
by fmw42
henrywho wrote:A small note that some ppls like to take BW (gray) photos but IM6 behaves weirdly with gray photos and -colorspace options. Better use -gamma with gray photos for the time being.
If you want to convert to grayscale in newer IM releases, it will be converted to linear. Before it was kept as non-linear sRGB. To get the old results add -set colorspace RGB before -colorspace gray.