python - 如何以编程方式删除黑色网格?

标签 python graphics imagemagick extract image-recognition

我的想法是:

  • 1.0. [unsolved, hard image-detection] Breaking image into squares and removing borders, surely other techniques!

  • 1.1. [unsolved] Imagemagick: crop (instructions here), remove certain borders -- this may take a lot of time to locate the grid, image detection problem (comparing white/black here) -- or there may be some magic wand style filter.

  • 1.2. [unsolved] Python: you probably need thisfrom PIL import Image.

显然,Gimp 的橡皮擦是解决此问题的错误方法,因为它速度慢且容易出错。您将如何以编程方式删除网格?

enter image description here

附言在 Graphics.SE 中随意讨论这个问题 here包含更多物理和机械技巧。

最佳答案

如果所有图像都由灰色网格上的黑线组成,您可以调整白色阈值以移除网格(例如使用 ImageMagick):

convert -white-threshold 80% with-grid.png without-grid.png

您可能必须对确切的阈值进行试验。 80% 的样本图像对我有用。这将使线条像素化。但也许重新采样可以将其减少到可接受的数量,例如与:

convert -resize 200% -white-threshold 80% -resize 50% with-grid.png without-grid.png

关于python - 如何以编程方式删除黑色网格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11342797/

相关文章:

python - GitLab CI 为 Python 共享 Windows 运行器

python - asyncio.run_in_executor 是否指定不明确?

Java:图形还是 Graphics2D?

perlmagick imagemagick 错误

php - 将多个 PDF 文件合并为一个页面 PDF - positioned join using PHP

python - 从列表中删除所有出现的值?

python - 以 UTF-32 编码的单个字符的长度

java - Swing 组件是如何在内部创建、布局、重绘、通知事件的,...?

android - 如何在 OPENGL ANDROID 中根据 x,y 坐标显示和移动图像

python - Imagemagick 或类似的脚本图像增强