如何识别主要颜色为白色但在计算中忽略 alpha 通道?

huangapple go评论61阅读模式
英文:

How can I identify images with a dominant color of white but ignoring the alpha channel in the calculation?

问题

I need to do exactly this post. I need to identify images with a dominant color of white.

I've tried the answer in the question I referenced above:

magick image -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1 -format "%[fx:100*mean]\n" info:

However, my images have an alpha channel, and it seems that is being taken into consideration during the calculation because the result I'm getting is 25 despite the image being pure white with transparency.

Here are a couple of example images (Note, they will look invisible since it's on a white background, but the images are in-fact there):

如何识别主要颜色为白色但在计算中忽略 alpha 通道?
如何识别主要颜色为白色但在计算中忽略 alpha 通道?
如何识别主要颜色为白色但在计算中忽略 alpha 通道?

Can someone help me identify white images while ignoring transparency in the mean calculation?

Really appreciate any help.

英文:

I need to do exactly this post. I need to identify images with a dominant color of white.

I've tried the answer in the question I referenced above:

magick image -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1 -format "%[fx:100*mean]\n" info:

However my images have an alpha channel and it seems that is being taken into consideration during the calculation because the result I'm getting is 25 despite the image being pure white with transparency.

Here are a couple example images (Note, they will look invisible since it's on a white background, but the images are in-fact there):

如何识别主要颜色为白色但在计算中忽略 alpha 通道?
如何识别主要颜色为白色但在计算中忽略 alpha 通道?
如何识别主要颜色为白色但在计算中忽略 alpha 通道?

Can someone help me identify white images while ignoring transparency in the mean calculation?

Really appreciate any help.

答案1

得分: 2

关闭 alpha 通道并使用 1x1!(注意!标记)在 Imagemagick 中。

magick white.png -alpha off -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1! -format "%[fx:100*mean]\n" info:

91.9187

或者

magick white.png -alpha off -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1! -format "%[fx:100*u]\n" info:

91.9187

<br>

我注意到你的白色图像在基本 RGB 图像和 alpha 通道中都有黑色。也许你应该让基本图像完全变为白色。

magick white.png -background white -alpha background -scale 1x1! -alpha off -format &quot;%[fx:100*mean]\n&quot; info:

99.9999
英文:

Turn the alpha channel off and use 1x1! (note the ! mark) in Imagemagick.

magick white.png -alpha off -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1! -format &quot;%[fx:100*mean]\n&quot; info:

91.9187

or

magick white.png -alpha off -fuzz 1% -fill white -opaque white -fill black +opaque white -scale 1x1! -format &quot;%[fx:100*u]\n&quot; info:

91.9187

<br>

I note that your white image has black in the base rgb image and also in the alpha channel. Perhaps you should make the base image perfectly white.

magick white.png -background white -alpha background -scale 1x1! -alpha off -format &quot;%[fx:100*mean]\n&quot; info:

99.9999

huangapple
  • 本文由 发表于 2023年6月13日 03:34:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76459786.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定