Find an image by nearest color?
Hi OpenCV’ers!
I’ve got a project in mind and need some expert input. I have a collection of about 1100 abstract images (desktop wallpaper tiles) that I want to be searchable by predominant color.
I’ve already found Python code to help me use the OpenCV libraries to do k-means clustering and extract the top 3 (for example) colors in each image. From that, I can get the three colors as RGB values and the percentage of each.
I plan to stuff all that data into a database for searching.
Ideally, I want the program user to select a color (using a standard color-picker dialog box), and then query the database for the top X images with the “closest matching” predominant color.
The problem is that I don’t know how to store and search this data effectively. That’s where I need your help. The math involved here is miles over my head.
From doing some reading (Wikipedia), I have a hunch that storing and searching HSV values makes more sense than RGB values. I can’t fully explain why, except that it seems easier to find “more or less blue-ish” using HSV.
Is anyone willing to help me untangle this? I thought this project would be straightforward, until I started digging into image analysis. This led me to k-means clustering, which led me here.
Thanks in advance.
Using kmeans you get a features for each images. If you keep N colors you will get a feature 4N (3 for rgb +1 for percentage).
You can use this post to build data space and try to get nearest image