使用 ImageMagick 清理扫描的灰度图像

Aar*_*lla 4 imagemagick image-processing image-scanner

我有很多文本页面的扫描(白底黑字)。

我通常的方法是使用 Curves 对话框使用只有四个点的非常简单的曲线来清理 Gimp 中的那些:0,0 - 63,0 - 224,255, 255,255

这使所有灰色文本变黑,并使文本更清晰,并将大部分白色像素变为纯白色。

如何使用 ImageMagick 或其他一些完全从命令行运行的 Linux 工具在脚本中实现相同的效果?

-normalize或者-contrast-stretch不工作,因为它们使用像素数进行操作。我需要一个运算符,它可以使颜色 0-63(灰度)变黑,224 纯白色以上的所有颜色,其余部分都应归一化。

Aar*_*lla 5

The Color Modifications page shows many color manipulation algorithms by ImageMagick.

In this specific case, two algorithms are interesting:

-level gives you perfect black/white pixels near the ends of the curve and a linear distribution between.

The sigmoidal option creates a smoother curve between the extremes, which works better for color photos.

To get a similar result like in GIMP, you can try to apply one after the other (to make text and black areas really black).

在所有情况下,您都需要先运行-normalize(甚至使用-contrast-stretch来合并大部分噪声)以确保没有浪费黑/白电平。如果没有这个,最暗的颜色可能会比rgb(0,0,0)纯白色更亮,而最亮的颜色可能会低于纯白色。

  • 我成功地转换了大量的 Doré Woodcuttings,扫描,在 * 中使用 `for 文件;做 mogrify -normalize -level 27%,76% $file; 完成`。我通过试验 gimp 中的曲线工具找到了 27% 和 73%。 (8认同)