欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

相似度--欧氏距离(归一化)

发布时间:2025/3/20 61 豆豆
生活随笔 收集整理的这篇文章主要介绍了 相似度--欧氏距离(归一化) 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

2019独角兽企业重金招聘Python工程师标准>>>

<!-- lang: cpp --> double CalcSimilarity(IplImage* S,IplImage* T)

{ double r = 0.f; int width = T->width; int height = T->height;

uchar* ptrS = NULL; uchar* ptrT = NULL; float a = 0,b = 0,c = 0; for(int i=0;i<height;i++) {ptrS = (uchar*)S->imageData+i*S->widthStep;ptrT = (uchar*)T->imageData+i*T->widthStep;for(int j=0;j<width;j++){a += ptrS[j]*ptrS[j];c += ptrT[j]*ptrT[j];b += ptrS[j]*ptrT[j];} }return b / (sqrt(a) * sqrt(c));

}

转载于:https://my.oschina.net/u/733649/blog/220737

总结

以上是生活随笔为你收集整理的相似度--欧氏距离(归一化)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。