What is the best filter for downsampling text?

I use ImageMagick to cut text. I understand that there is no such thing as a better filter for each situation, but I think that there should be a generally accepted standard when it comes to downsampling text (I could be wrong). Here is a list of filters available in ImageMagick:

  • Bartlett
  • Blackman
  • Bohman
  • Box
  • Catrom
  • Cubic
  • Gaussian
  • Hamming
  • Hanning's
  • Hermite
  • Jinc
  • Kaiser
  • Lagrange
  • Lanczos
  • LanczosSharp
  • Lanczos2
  • Lanczos2sharp
  • Mitchell
  • Parzen
  • Point
  • Square
  • Robidou
  • Sinc
  • Sincfast
  • Triangle
  • Welsh
+6
source share
2 answers

There is no generally accepted downsampling filter; simply because there is no generally accepted font for text. You will need to determine the font (s) you are working with and apply the best match filter for the specified task.

  • Processing letters since 2005? Tahoma font => Hermite's filter
  • Scanned faxes? Mixed High Contrast => Spot Filter

A visual comparison of each filter and its weakness can be found here and here .

I like to remind myself which filter will complete the task by creating a visual cheat sheet.

Downsampling example

Here's a quick bash script preview of "DejaVu Sans Condensed"

#!/bin/bash # Adjust this to type-face you'd like to preview FONT_TO_PREVIEW="DejaVu-Sans-Condensed-Bold" # Create a temp directory to work with mkdir filter_tmp cd filter_tmp while read filter do # Generate base file convert \ -gravity center -font $FONT_TO_PREVIEW -background white -size 126x \ -fill black -pointsize 12 label:$filter $filter.org.png # Resample convert $filter.org.png -filter $filter -resize 400% $filter.filter.png # Crop center mogrify -gravity center -crop 126x+0+0 +repage $filter.filter.png # Tile filtered image below original montage $filter.org.png $filter.filter.png -tile 1x2 -geometry +1+1 +label +set label $filter.png # Clean house rm $filter.filter.png $filter.org.png # Generate list of all installed filters done < <(identify -list filter) montage -geometry +4+4 -tile 4x *.png ../filter_preview.png # Clean house & display generated filter preview cd .. rm -rf filter_tmp display -display :0 filter_preview.png 
+14
source

Your cheat sheet does not use some of the filters as recommended: some of them are designed to be used with "-distort Resize" instead of "-resize" ( see here ).

Additional recommendation: choosing a color space can really improve (or worsen) the results. Message from ImageMagick Forums "Enlarge with sRGB, RGB, LAB, LUV, XYZ, sigmoid ...?" (which I cannot link here because, as a new user, I can only put two links for each answer) illustrates this. With text, I recommend "sigmoidization" with high contrast (above 11). See here .

+2
source

All Articles