put averageColor method to image category, tidy the code