Commit 29bb3e9a by Иван Кубота

more products

parent 2469f250
...@@ -255,22 +255,39 @@ var extractor = function(partName, ctx, from, k, debug) { ...@@ -255,22 +255,39 @@ var extractor = function(partName, ctx, from, k, debug) {
var used = {}; var used = {};
var all = [].concat.apply([], var all = [].concat.apply([],
colors.map(function(clr) { colors.map(function(clr) {
var epsilon = 0.033;
var matched = list.map(function(i) { var matched = list.map(function(i) {
return {i: i, d: hsvDistance(i.hsv, clr.hsv), c: clr}; return {i: i, d: hsvDistance(i.hsv, clr.hsv), c: clr};
}) })
.filter(function(i) { .filter(function(i) {
return i.d<0.07; return i.d<epsilon;
}) })
.sort(function(a,b) { .sort(function(a,b) {
return a.d-b.d; return a.d-b.d;
}); });
if(!matched.length) var lastMatched = matched;
while(matched.length > 5){
epsilon = epsilon/3*2;
matched = matched.filter(function(i) {
return i.d<epsilon;
});
if(matched.length===0){
matched = lastMatched;
break;
}
lastMatched = matched;
}
/*if(!matched.length>3){
matched = matched.f;
return matched; return matched;
if(matched[0].d<0.02){ }*/
/*if(matched[0].d<0.02){
return matched.slice( 0, 1 ) return matched.slice( 0, 1 )
}else{ }else{
return matched.slice(0, 2); return matched.slice(0, 2);
} }*/
return matched;
})).filter(function(item) { })).filter(function(item) {
if(!(item.i.vid in used)){ if(!(item.i.vid in used)){
used[item.i.vid] = true; used[item.i.vid] = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment