代码之家  ›  专栏  ›  技术社区  ›  DevonDahon

ImageMagick:填充大洞

  •  0
  • DevonDahon  · 技术社区  · 7 年前

    如何填补黑白图像中的大洞 图像贴图 ,就像在第6行第1列的元素中一样?

    enter image description here

    ===增加===

    实际上,我需要像下面的那个一样,用一个面具填充内部的孔和孔。有了Gimp,我会的 模糊选择 背景, 使转化 选择, 成长 20像素, 收缩 20像素,然后 编辑>用前景颜色填充 .

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  1
  •   fmw42    7 年前

    这看起来和你最近的其他帖子很相似 ImageMagick: Is there an equivalent of Gimp's tool to "shrink" and "grow" a selection? .

    对于小孔,-形态将起作用。但是如果你的洞大于黑色区域之间的距离,黑色区域就会合并。

    最好的方法是使用ImageMagick连接的组件。这不会在区域之间流血。但是如果你的洞比任何一个黑色区域都大,那么这些黑色区域如果超过了区域阈值,就会合并成白色。

    convert image.png \
    -define connected-components:area-threshold=500 \
    -define connected-components:mean-color=true \
    -connected-components 4 \
    result.png
    


    enter image description here