英文:
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):
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):
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 "%[fx:100*mean]\n" 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 "%[fx:100*mean]\n" info:
91.9187
or
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>
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 "%[fx:100*mean]\n" info:
99.9999
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论