opencv - 如何在 opencv c++/opencv java 中使用 fred 的 imagemagick textcleaner 脚本?

标签 opencv image-processing tesseract

我正在尝试开发一个可以从图像中读取文本的应用程序。我必须清理图像的背景。我听说可以使用 fred 的 imagemagick textcleaner 脚本,但我不知道如何使用它。有人对此有任何想法吗?

输入图像:

enter image description here

最佳答案

我尝试过这个,虽然这个消息不是很好,但它仍然是一个答案,即使是否定的。也许其他人想要进一步努力,或者您觉得我的努力证实了 textcleaner 不是可行的方法。不管怎样,我拍了你的照片并写了一个脚本来改变 Fred Weinhaus 的 textcleaner 最有希望的参数。我觉得可能有帮助的是 -f-o-t,我通过它们可能的范围改变了它们,如下所示:

#!/bin/bash
for f in 1 5 10 15 20 25; do
   for o in 1 3 6 9 12; do
      for t in 1 25 50 75 100; do
         ./textcleaner -f $f -o $o -t $t cc.jpg z_${f}_${o}_${t}.png
         convert -label "f=$f, o=$o, t=$t" z_${f}_${o}_${t}.png miff:-
      done
   done
done | montage - -frame 5 -tile 6x montage.png

这给了我所有结果的剪辑

enter image description here

在我看来,最有希望的可能是 f=10、o=1、t=1

enter image description here

然后我想“为什么要费心看我喜欢的东西,让我们看看 Tesseract 喜欢什么?”。所以我将脚本更改为此,以便 Tesseract 可以查看所有排列:

#!/bin/bash
for f in 1 5 10 15 20 25; do
   for o in 1 3 6 9 12; do
      for t in 1 25 50 75 100; do
         ./textcleaner -f $f -o $o -t $t cc.jpg z_${f}_${o}_${t}.png
         tesseract z_${f}_${o}_${t}.png res > /dev/null 2>&1
         if grep "[0-9]" res* ; then echo z_${f}_${o}_${t}.png ;fi
      done
   done
done

结果很糟糕……这是输出

um 0-" V _
L"“1}- H
z_5_3_50.png
:1:J£‘u  “
z_15_3_75.png
”':{E]!)  /3: '55‘
z_15_6_75.png
 E2?
z_15_9_1.png
:1:
z_15_12_100.png
I -.352}:  "H ,1 5
z_20_12_25.png
1/
, ,5». 3».
z_25_6_75.png
 3
z_25_9_25.png
 - ::'§—:am I-:L’5‘:*‘f§~f.’i'7""“-‘-"I 5="
z_25_12_1.png
7 3:2‘
z_25_12_75.png

没有任何用处。也许其他人对如何调整它以及调整哪些参数有更好的想法,但我怀疑 textcleaner 在这里可能是错误的方法。

关于opencv - 如何在 opencv c++/opencv java 中使用 fred 的 imagemagick textcleaner 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29405555/

相关文章:

algorithm - 监督运动检测库

c - 如何识别图像来自针式打印机

c++ - cv::Mat_ 是否保持其投资返回率?

python - 删除图像的上角部分

android - 如何在 Compose UI Android Jetpack 中将 url 加载到 Image 中?

opencv - 如何更改在 OpenCV 中使用 Umat 执行 OpenCL 代码的设备?

java - Tess4j 不使用它的 tessdata 文件夹

tesseract 无法识别一个数字图像

c++ - 从 Python 调用 C++ opencv 函数(将 cv::Mat 发送到使用 opencv 的 C++ dll)

python - 如何在棋盘图像中找到空方 block ?