我正在寻找一种方法来删除始终相同文本和相同位置(对角线)的图像的文本(水印)。
我发现了一些类似的问题,并且在一些建议中“填补文本位置中的漏洞”,但最初我陷入了如何在文本位置中创建“如何”的问题。 也许有人可以帮忙。问候
更新这是我到目前为止的代码,遵循
这种技术,但输出与我想要的相距甚远。
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
到目前为止的输出。
创建蒙版:
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
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
输入: