ImageMagick:删除白线 [英] ImageMagick : remove white lines

查看:175
本文介绍了ImageMagick:删除白线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试去除可能成像的白色线条。

I'm trying to remove white lines which cute in pieces an image.

我正在使用:

convert input.png -fill white +opaque "#e6e6e6" -fill black -opaque "#e6e6e6" -median 2 -magnify result.png

使用以下输出删除背景:

to remove the background with the following output :

如何使用ImageMagick删除这些白线?

How could I remove those white lines using ImageMagick ?

谢谢

推荐答案

您可以使用已引入ImageMagick的形态运算符,特别是 dilation 运算符。它会增长图像的白色区域,这与你想要的相反,所以我们首先否定图像,使黑色变白,做形态然后否定回原来。

You could use the morphological operators that have been introduced into ImageMagick, specifically the dilation operator. It grows the white regions of the image, which is the opposite of what you want so we negate the image first, making blacks white, do the morphology then negate back to your original.

由于间隙沿着水平线,我们需要一个垂直结构元素用于形态学,因此我们可以使用一个像素宽和几个像素高的垂直线 - 我选择了9个像素。总而言之,你的命令如下:

As the gaps are along a horizontal line, we want a vertical structuring element for the morphology, so we can use a vertical line one pixel wide and several pixels tall - I chose 9 pixels. So, all in all, your command looks like this:

convert in.jpg -negate -morphology dilate rectangle:1x9 -negate out.jpg

结果如下:

这篇关于ImageMagick:删除白线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆