ImageMagick如何去除背景噪声

3
为了更好地准备OCR过程,我想在我的图像上去除背景噪声(通常是扫描图像)。
这是示例:

enter image description here

有没有使用magick.exe命令去除像这样的图像噪声的方法?如果有,能否举个例子。

更新:

我在Windows 10上使用ImageMagick-7.0.7-Q16。

1个回答

6
使用ImageMagick中的-connected-components命令来减少噪声。(Unix语法)
convert \
3foBc.png -threshold 60% \
-define connected-components:verbose=true \
-define connected-components:area-threshold=5 \
-define connected-components:mean-color=true \
-connected-components 8 \
out.png

enter image description here


感谢您的回答。我正在尝试在Windows 10机器上执行以下命令:magick.exe convert image_59.jpg -threshold 60% -define connected-components:verbose=true -define connected-components:area-threshold=5 -define connected-components:mean-color=true -connected-components 8 out.jpg 但是它出现了以下错误: convert: invalid argument for option '-threshold': 60verbose=true @ error/convert.c/ConvertImageCommand/3009. - alexanoid
删除“convert”。在ImageMagick 7中,它只是magick。在Windows中,我相信百分比需要加倍为60%%。抱歉,我不是Windows用户。请参阅http://www.imagemagick.org/Usage/windows/。 - fmw42
我在这个问题的图像上尝试了这个解决方案,看起来它正在工作,但我也尝试了另一个 jpg 图像,它失败了。在转换之前,我需要将 jpg 转换为 png 或其他格式吗? - alexanoid
JPG颜色太多了。最好将颜色限制在黑白之间。这就是为什么我首先使用了“-threshold 60%”。 - fmw42

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接