gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 13:49:55 25 4
gpt4 key购买 nike

我的想法是:

  • 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com