sorting images by color sorting images by color php php

sorting images by color


I've never done something like this myself, so forgive me if the following approach is naive:

  • For each image, boil it down to 1 average RGB value by summing the R, G, B values of all pixels, and divide by the total # pixels. Normalize the components to [0..1]
  • Plot the image in your 2D color space based on the RGB values. This can be a 2D projection of a 3D (r, g, b) vector transformation.


you could convert to HSV and sort by H

Hue is what most people think of when they think "color"

see: RGB to HSV in PHP


Group similar colors using the distance between them and not between them and black, and use the average color in the image.