2012-05-31 242 views

回答

5

我会裁剪到你有兴趣,然后调整其大小的区域到1个像素。然后获取该像素的值。

13

扩大Bonzo’s answer。这是一个例子命令

convert Y82IirS.jpg -resize 1x1 txt: 

结果

# ImageMagick pixel enumeration: 1,1,255,srgb 
0,0: (220,176, 44) #DCB02C srgb(220,176,44) 

Average colour of an image

0

下面是同时处理作物和颜色检测的命令,并且还产生输出以一致的R,G,B格式:

convert image.gif -crop 6x7+8+9 -resize 1x1\! -format "%[fx:int(255*r+.5)],%[fx:int(255*g+.5)],%[fx:int(255*b+.5)]" info:- 

其中,在6x7+8+9

6: image width (pixels) 
7: image height (pixels) 
8: x-coordinate of top left corner 
9: y-coordinate of top left corner 

返回

176,191,67 

https://stackoverflow.com/a/25488429/3124680

改编