使用ImageMagick清洁扫描的灰度图像 [英] Cleaning scanned grayscale images with ImageMagick

查看:172
本文介绍了使用ImageMagick清洁扫描的灰度图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对文本页面进行了大量扫描(白色背景上的黑色文本)。

I have a lots of scans of text pages (black text on white background).

我通常的方法是使用曲线对话框清除Gimp中的文本页面。只有四个点的非常简单的曲线:0,0 - 63,0 - 224,255,255,255

My usual approach is to clean those in Gimp using the Curves dialog using a pretty simple curve with only four points: 0,0 - 63,0 - 224,255, 255,255

这使得所有灰色文本音高黑色加上使文本更清晰并且变得最多白色像素纯白色。

This makes all the greyish text pitch black plus makes the text sharper and turns most of the whitish pixels pure white.

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

How can I achieve the same effect in a script using ImageMagick or some other Linux tool that runs completely from the command line?

-normalize -contrast-stretch 不起作用,因为它们使用像素计数。我需要一个操作符,它可以使颜色0-63(灰度)漆黑,一切都高于224纯白色,其余的应该标准化。

-normalize or -contrast-stretch don't work because they operate with pixel counts. I need an operator which can make the colors 0-63 (grayscale) pitch black, everything above 224 pure white and the rest should be normalized.

推荐答案

颜色修改页面显示了ImageMagick的许多颜色处理算法。

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

在这种特殊情况下,两种算法很有意思:

In this specific case, two algorithms are interesting:

  • -level
  • -sigmoidal-contrast

-level 为您提供靠近曲线两端的完美黑/白像素和线性分布。

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

S形选项在极端之间创建更平滑的曲线,这对于彩色照片效果更好。

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

要获得类似GIMP的结果,您可以尝试一个接一个地应用(使文本和黑色区域真的变黑)。

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)更亮,最亮的颜色可能低于纯白色。

In all cases, you will want to run -normalize first (or even -contrast-stretch to merge most of the noise) to make sure no black/white levels are wasted. Without this, the darkest color could be lighter than rgb(0,0,0) and the brightest color could be below pure white.

这篇关于使用ImageMagick清洁扫描的灰度图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆