@Gargron

I wouldn't use the average color, but the most dominant colors in an image. Also pre-cropping and edge detection may help here to center on the focused part of the image.