If you have an image and you are looking for an average color that can best represent the image, you can use ImageMagick to reduce the image to just one pixel, then extract the pixel color.
convert input.png 1x1\! -format '%[fx:int(255*r)],%[fx:int(255*g)],%[fx:int(255*b)]' info:-
The command above will output a string consisting of the values for red, green and blue, separated by commas. You can further process these values for whatever purpose you need.