填充孔以删除特定位置的文本?

问题描述 投票:0回答:1

我正在寻找一种方法来删除始终相同文本和相同位置(对角线)的图像的文本(水印)。

我发现了一些类似的问题,并且在一些建议中“填补文本位置中的漏洞”,但最初我陷入了如何在文本位置中创建“如何”的问题。 也许有人可以帮忙。问候

enter image description here

更新

这是我到目前为止的代码,遵循

这种技术

,但输出与我想要的相距甚远。 magick -size 530x398 xc:black -stroke white -strokewidth 45 -draw 'stroke-linecap round line 105,321 465,60' -threshold 10% input_mask.jpg magick input.jpg \( input_mask.jpg -negate \) -compose CopyOpacity -composite input_hole.png magick input_hole.png -blur 0x1 -alpha off input_fill.png magick input_hole.png input_fill.png -compose Dst_Over -composite input_text_removed.png

到目前为止的输出。

enter image description here

imagemagick image-manipulation
1个回答
0
投票

创建蒙版:

Line1: convert input to HSV and separate channels Line2: convert the Value channel to fill the black vertical line with white Line3: invert (negate) and threshold at zero Line4: apply open morphology to get rid of the white specks around the letter Line5: dilate to fill in the letters to make the mask convert img.png -colorspace HSV -separate x.png convert x-2.png -fuzz 50% -fill white -opaque black x-2b.png convert x-2b.png -negate -threshold 0 x-2c.png convert x-2c.png -morphology open diamond:2 x-2d.png convert x-2d.png -morphology dilate disk:6 x-2e.png

然后进行输出:

blur the input and composite the blurred image with the input using the mask convert img.png \( +clone -blur 0x5 \) \( x-2e.png \) -compose over -composite x-2f.png

或者使用OP提供的链接中的方法从x-2e.png开始:

Line1: negate the mask and put it into the alpha channel of the input Line2: blur that image and turn the alpha channel off Line4: composite the the result of Line2 under the result of Line1 to form the output convert img.png \( x-2e.png -negate \) -alpha off -compose copy_opacity -composite x-2g.png convert x-2g.png -blur 0x4 -alpha off x-2h.png convert x-2g.png x-2h.png -compose dst_over -composite x-2i.png

输入:

enter image description here 价值渠道:

enter image description here 反转和阈值化:

enter image description here 打开形态以去除斑点:

enter image description here 形态扩张以创建掩模:

enter image description here 第一个结果:

enter image description here 将否定掩码放入输入的 Alpha 通道中:

enter image description here 模糊

enter image description here 第二个结果:

enter image description here 选择您最喜欢的一个。对我来说,两者似乎都不太好。

© www.soinside.com 2019 - 2024. All rights reserved.