The following content was retrieved from eooes.me, and published on Sunday, September 23rd, 2012
(โปรเจกต์ปี 2011 วิชา data retrieval, SIIT) – I know I know, This was done by google and other sites long ago. But I want to implement this function my own way. It is fun to play with… but I see other did better than mine, so… here is now I did
Tell me about it
This is the idea, program divides the picture into 9 parts, calculates the color use of each part by saving as RGB(could be done in any other format) or hsv whatsoever, but it could turn better result in hsv. so now each part has R and G and B value, the program then does normalization, put into database.
*Each pixel will be extracted the RGB value by the range of each value will be in between 0 and 255. For instance, to get the R value of one part, we need to get to each pixel and add the R value of each pixel together. Same method will be applied in order to get G and B value of one part.
Another word, for each part we sum every Red, Green Blue value, into 3 row data and normalize it to scale of 0-1
Above picture : SEARCH BY COLOR INPUT 9 OF BLUE
HOW TO SEARCH?
So now we have the database of the picture, how do we search? :
Euclidean distance (I only use knowledge from elementary school), so find the difference of input value from user and value of each picture in the database. The less means close value which means likely to have the same color.
Above picture : SEARCH BY COLOR INPUT 9 OF RED
Blow picture is a good example, the input is total blue for part 1 -6 and brown for part 7-9. This is not bad is't it, But the last picture is green, probably because I don’t have enough database (last experiment, it runs on 1200 pictures in database). And you may wonder what if the pictures are black and white, Sorry to say that this program does not support B&W.
Above picture : SEARCH BY COLOR INPUT 6 BLUE AT TOP AND 3 BROWN AT BOTTOM
For future development
- I would divide the picture into 16 or more, to improve accuracy.
- I would moved to Python, just for fun.
- More pictures, last time I only used 1200 pictures. >100k pictures would be good, so I can see the performance
- HSV maybe, and compare the result between each color mode
- This does not work with gray black white picture, I have to implement a way to solve this problem
This was done by PHP and C++ (Openframework, to be precise).