return arr;
}
function cosine(arr1, arr2) {
var axb = 0,
a = 0,
b = 0;
for (var i = 0, len = arr1.length; i < len; i++) {
axb += arr1[i] * arr2[i];
a += arr1[i] * arr1[i];
b += arr2[i] * arr2[i];
}
return axb / (Math.sqrt(a) * Math.sqrt(b));
}
function gray(imgData) {
var data = imgData.data;
for (var i = 0, len = data.length; i < len; i += 4) {
var gray = parseInt((data[i] + data[i + 1] + data[i + 2]) / 3);
data[i + 2] = data[i + 1] = data[i] = gray;
}
return imgData;
}
本文地址:https://www.stayed.cn/item/24096
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我