Imagemagick无法在没有丑陋的边缘的情况下变成透明的白色

发布于 2025-01-27 22:46:15 字数 2427 浏览 0 评论 0原文

我正在尝试从5k+图片中删除白色,然后将其变成透明。不幸的是,当我这样做时,它以各种灰色的色调在黑色零件周围留下了丑陋的边缘。

我尝试了各种方法,包括-trim和-fuzz,但无法使其正常工作。它要做的就是删除白色,并留下其他所有作用。

我必须摇动绒毛,以使箭头看起来远程看起来有点正确,那个成像策略将删除其他应该不应该的东西。

有人可以帮我吗?

原始图像:

使用ImageMagick后图像(添加了绿色,您可以更好地看到丑陋的边缘):

使用ImageMagick(Original)

“在此处输入图像说明”

所以我想要的是从图片中删除所有白色并使这些白色使这些白色并使这些透明。其他任何事情都不应受到影响。

该图像是在Illustrator中以8K分辨率制作的,然后我将其导出到单个PNG图像(透明)。然后,我将Bramus的瓷砖切割器脚本用于Photoshop将我的图像切成瓷砖(不幸的是,这迫使白色背景)。

因此,最终我想尝试ImageMagick去除白色,但是您可以读到,我无法到目前为止。

希望有人可以帮助我。

我当前使用的代码:

for /R "C:\Users\<Username>\Desktop\map" %I in (*.png) do magick "%I" -fuzz 69% -transparent #FFFFFF "%I"

将其放在另一层的顶部时应该是什么样子:

“在此处输入映像”

我尝试增加Blur 0x2,例如,在有效的大图片上,更好,但是较小的图片损失了很多细节,几乎看不见线条。它要么是大图是Oké,要么是低图片是Oké,但是无论我尝试什么,这都不是两者。

模糊设置为0x2的较小图像的样本。您也可以看到一些白色也留在那里。

如果有帮助,我可以将几个小的,常规和大图像用于测试目的吗?

原始文件: https://easyupload.io/8yep41

使用ImageMagick之后: https://easyupload.io/6xlm2f

单个图像比较: ///easyupload.io/gi5dvm“ rel =“ nofollow noreferrer”> https://easyupload.io/gi5ddvm

我使用的命令是:

for /R "C:\Users\<Username>\Desktop\map\<FolderName>" %I in (*.png) do magick "%I" -fuzz 10% -transparent white ( +clone -alpha extract -blur 0x1.2 -level 50x100% ) -alpha off -compose copyAlpha -composite "%I"

所以我要么在低zoom上几乎消失了箭头(例如4个(4) ),但没有6个或我有白色边界。我也多次在箭头头上留下了白色斑点。

I am trying to remove the white from 5k+ pictures and turn it into transparent. Unfortunately, when I do this it leaves a ugly edge around the black parts in various gray tones.

I tried various methods including -trim and -fuzz but I am unable to get it working properly. All it should do is remove the white and leave everything else intract.

I have to crank the fuzz so high for the arrows to remotely look a little bit properly, that ImageMagick will remove other stuff that it shouldn't as well.

Can someone help me out please?

The original image:
enter image description here

The image after using ImageMagick (added green so you can see the ugly edge better):
enter image description here

The image after using ImageMagick (original)

enter image description here

So basically what I want is to remove all white from the pictures and make those transparent. Anything else should NOT be affected.

The image was made in 8k resolution in Illustrator which I then exported to a single PNG image (transparent). Then I used Bramus' tile cutter script for Photoshop to cut my image into tiles (which forces a white background unfortunately).

So finally I wanted to try ImageMagick to remove the white but as you can read, I am unable to so far.

Hope someone can help me out.

The code I currently used:

for /R "C:\Users\<Username>\Desktop\map" %I in (*.png) do magick "%I" -fuzz 69% -transparent #FFFFFF "%I"

What it should look like in the end when I put it on top of my other layer(s):

enter image description here

I tried increasing the blur 0x2 for example, on big pictures that works better, but the smaller pictures lose to much detail and the lines are barely visible. It is either big pictures are oké or low pictures are oké but never both so far whatever I try.

A sample of a smaller image with the blur set to 0x2. You can see some white was left there too.

enter image description here

If it helps, I can zip a couple of small, regular and big images for testing purposes?

Original files: https://easyupload.io/8yep41
After using ImageMagick: https://easyupload.io/6xlm2f

Single image comparison: https://easyupload.io/gi5dvm

The command I used is:

for /R "C:\Users\<Username>\Desktop\map\<FolderName>" %I in (*.png) do magick "%I" -fuzz 10% -transparent white ( +clone -alpha extract -blur 0x1.2 -level 50x100% ) -alpha off -compose copyAlpha -composite "%I"

So I either have almost disappearing arrows on the low zoom ones (4 for example) but not on 6 or I have white borders. I also have white spots left at the arrow heads in multiple occasions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滴情不沾 2025-02-03 22:46:15

在Windows上的ImageMagick 7中,您可以执行

magick arrow.png -fuzz 10% -transparent white ^
( +clone -alpha extract -blur 0x1 -level 50x100% ) ^
-alpha off -compose copyAlpha -composite ^
new_arrow.png

”在此处输入图像描述“

如果在.bat脚本中,我相信您需要将%翻倍到%%。

加法

尝试以下方法:

magick 17_original.png -fuzz 10% -transparent white ^
( +clone -alpha extract -blur 0x1.2 -level 85x100% ) ^
-alpha off -compose copyAlpha -composite ^
-background "rgb(6,120,0)" -alpha background -alpha off ^
17_original_green_fred.png

”在此处输入图像说明”

In Imagemagick 7 on Windows, you can do

magick arrow.png -fuzz 10% -transparent white ^
( +clone -alpha extract -blur 0x1 -level 50x100% ) ^
-alpha off -compose copyAlpha -composite ^
new_arrow.png

enter image description here

If in a .bat script, I believe that you would need to double the % to %%.

ADDITION

Try this:

magick 17_original.png -fuzz 10% -transparent white ^
( +clone -alpha extract -blur 0x1.2 -level 85x100% ) ^
-alpha off -compose copyAlpha -composite ^
-background "rgb(6,120,0)" -alpha background -alpha off ^
17_original_green_fred.png

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文