how to implement color search with sphinx? -
searching photo dominant colors using mysql quite simple. assuming r,g,b values of dominant colors of photo stored in database, achieved example like:
select * colors abs(dominant_r - :r) < :threshold , abs(dominant_g - :g) < :threshold , abs(dominant_b - :b) < :threshold
i wonder, if it's anyhow possible store colors in sphinx , perform querying using sphinx search engine?
thanks!
i have done search colors sphinx. it's there http://code.google.com/p/hppg/. how works? simple, each color store it's dominant colors in database. database table, witch used sphinx indexing, has column named "colors", it's content filled in following way:
/** * part changed based on formula * * fits here better algorithm * * http://en.wikipedia.org/wiki/tag_cloud * 15400 number of maximum matches based on indexed thumbnail size 120x130 px. * */ $max = 15400; $min = 25; $rmax = 50; $rmin = 1; $colorindex = array(); foreach ($colorsmaximumimage $color) { $colorindexstring = trim(str_repeat(' pld'.$color['pallete_id'],round((($rmin*($color['count']-25))/($max-$min))*100))); if ($colorindexstring != '') $colorindex[] = $colorindexstring; }
i used tagging formula here, avoid big index. count number of times custom pallete item matched. works fine, examples of live sites can found @ project home page. such way can search color , keyword @ same time :). i'm still experimenting best result of it...
Comments
Post a Comment