Replace average algorithm by colours ordered by how often they occur in the source image