带有ImageMagick的多个图像中的散装提取物占主导地位
我想从使用ImageMagick中提取最主要的颜色的许多图像。使用此脚本:
area=$(magick *.png -format "%[fx:w*h]" info:)
magick *.png -kmeans 10 -format "%c" histogram:info: | sed 's/://g' | awk -v area=$area '{print 100*$1/area, "%,", $3}' | sed 's/ *//g' | sort -nr -k1,1 -t ","
我可以在文件夹中的.png中获取有关颜色的大量信息,但是我看不到信息与哪个图像有关!
我还查看了此脚本:
convert *.png -gravity center -crop 1x1+0+0 -format "%f,%[fx:int(mean.r*255)],%[fx:int(mean.g*255)],%[fx:int(mean.b*255)]\n" info:
它在每个图像中心的像素上都提供了很棒的工作,但是我看不到我缺少的是获得第一个输出原始文件名的脚本和该文件中的主要颜色?我现在真的很困难,而且我敢肯定这是非常明显的!
I've a number of images that I want to extract the most dominant colors from using Imagemagick. Using this script:
area=$(magick *.png -format "%[fx:w*h]" info:)
magick *.png -kmeans 10 -format "%c" histogram:info: | sed 's/://g' | awk -v area=$area '{print 100*$1/area, "%,", $3}' | sed 's/ *//g' | sort -nr -k1,1 -t ","
I can get a lot of information about the colors in the .pngs in my folder, but I can't see which of the images the information relates to!
I have also looked at this script:
convert *.png -gravity center -crop 1x1+0+0 -format "%f,%[fx:int(mean.r*255)],%[fx:int(mean.g*255)],%[fx:int(mean.b*255)]\n" info:
Which does a great job of giving me info on the pixel in the center of each image, but I can't see what I'm missing to get the first script to output the the original file name and the dominant colors in that file at all? I'm really stumped now, and I'm sure it's something super obvious!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您将不得不在图像上写一个脚本循环,而不是在输入中使用通配符。 ImageMagick只会在列表中的第一个图像上报告。如果您使用脚本循环,则可以执行诸如Convert image.suffix -set文件名之类的事情:f“%t _%[平均值]“”%[filename:f] .suffix”。请参阅ImageMagick.org/script/escape.php
例如:
输入:
结果(lena_180_99_99.png):
I think you will have to write a script loop over your images rather than using wild cards in the input. Imagemagick will only report on the first image in the list. If you use a script loop, then you can do something like convert image.suffix -set filename:f "%t_%[mean]" "%[filename:f].suffix". See imagemagick.org/script/escape.php
For example:
Input:
Result (lena_180_99_99.png):