Last modified: 2013-09-27 18:10:34 UTC
We use a lot of historic media, for obvious reasons. Unfortunately, engravings, a very common type, often have large numbers of not-quite-horizontal lines. This results in bad thumbnailing at times. For example: http://upload.wikimedia.org/wikipedia/commons/thumb/1/16/Rajpoots_2.png/310px-Rajpoots_2.png is not a very good thumbnail of http://upload.wikimedia.org/wikipedia/commons/1/16/Rajpoots_2.png Is there anything that can be done?
Note that image may be a good test: MOST thumbnails have some sort of Moiré in the sky.
Sure, if we start scaling each image by hand, picking the best algorithm. All is a trade off between speed, quality and sharpness. And the bigger the image, the worse the effects can be of course. See also: http://www.imagemagick.org/Usage/resize/#filter Specifically: http://www.imagemagick.org/Usage/resize/#best_filter
Ah, well. Figured it was going to be something like that. ~~~~
http://commons.wikimedia.org/wiki/File:Rajpoots_2-scaled.tif Another example for people who will want to work on this and test scaling routines.
Created attachment 9065 [details] Sample scale-downs using ImageMagick & gimp Adding a Gaussian blur on the original image before scaling seems to work wonders for this engraving; a 10x10 blur in Gimp for 310px or a 2x2 blur for 1600px both come out looking fairly smooth. Blurring may however be relatively slow, especially on large images; it's probably not the best idea to turn it on as a default. However.... I notice I actually get very good results using ImageMagick's '-resize' mode instead of '-thumbnail'. By default -resize applies a Mitchell filter; I can also apply '-filter Gaussian' which looks not quite as sharp. The -filter option seems to be ignored by -thumbnail; or if it is applied it looks like it happens after a much more primitive resampling which'll be what gives us the heavy moire: http://www.imagemagick.org/Usage/resize/#thumbnail Of course part of the reason we use -thumbnail is probably because it's fast because it doesn't do all that filtering at full resolution. :P Being able to flip particular images into the slower, more filtered scaling may actually be useful -- I suspect a simple on/off will be sufficient. But I don't know what performance impact it'll have; very large source images with high contrast are the target group, but very large source images are the exact ones that are slow and use lots of memory to resize. :(
Notes from VIPS scaler test on this image: http://lists.wikimedia.org/pipermail/wikitech-l/2011-November/056705.html
Created attachment 9589 [details] Some frequency spectra A comparison showing the issue in the frequency domain. The left image is the frequency spectrum of the source (VIPS im_fwfft + im_scaleps). Note the strong peaks on the X and Y axes representing the engraving pattern. The middle image has a 10px block average applied, like what VIPS im_shrink uses. Note the notches in the response which suppress part of the engraving pattern. The right image used a 10px radius Gaussian filter like what Brion used in one of his comparison images. Note the circular symmetry in the central area and rapid falloff out of the pass band. If you're reducing the image far enough that the engraving pattern will generate Moire fringes, you need to use a filter which will strongly attenuate the part of the frequency spectrum where the engraving pattern is located.
Interestingly enough, vips appears to give better results for that test case - https://test.wikipedia.org/wiki/Special:VipsTest?file=Rajpoots_2.png&width=640&sharpen=0