php - Group photos by color -


I have a large number of photos and a RGB color map (we say about 100 colors). How can I group images with colors and get something like the following?

My current idea is: Using ImageMagick, do this for each picture:

  1. Size it
  2. To get this color Get photos for, how often each color appears
  3. >
  4. Store colors in a database, but I do not know what is the best way to do this for faster recovery. Do you know in a better and more efficient way to do this? My language of choice is php because all heavy processing will be done by the image magic, and the database is PostgreSQL. Thanks in advance!

I have already explored how to get the most relevant colors from the image. The size of the images is not very high because the histogram can look different.

The database might look like this:

Image Table:

  image_id | Image_file  

color table:

  color_id | Color_rgb  

image_color table:

  image_id | Color_id | Color_percent  

The color_percent column will be used for the group / where segment

getting images:

  select image_id sum (color_percent) ) / Count (Color_percent) as a relevance to image_color where color_id IN (175, 243) # such colors you want to include in this search and color_percent & gt; 10 # By relevance  
image_id will leave results with less importance group

Comments