图像相似度比对,可用于图像识别,制作辅助时,区分是什么,
程序步够:
1,获取图像的局部像素到数组
2,把像素数组进行直方图计算
3,把2组直方图数据进行巴氏系数计算
最后得出,0--1 的数值,1为100%匹配, 0为 0% 匹配。
需要源码的,请加【Basic语言编程精英群】QQ群号:78458582 ,在群文件里下载。
Function HistogramCompute(nBy() As Long, Hm() As Single) As Long '直方图计算
'nBy(y,x) 像素数组 Hm(256 * 3 -1) 直方图值
Dim As Long r, g, b, x, y, t, u
u = 256 * 3 -1
ReDim Hmj(u) As Long
For y = 0 To UBound(nBy, 1)
For x = 0 To UBound(nBy, 2)
r = GetRValue(nBy(y, x))
g = GetGValue(nBy(y, x))
b = GetBValue(nBy(y, x))
t = r * 3 + 0 : Hmj(t) += 1
t = g * 3 + 1 : Hmj(t) += 1
t = b * 3 + 2 : Hmj(t) += 1
Next
Next
ReDim Hm(u)
t = (UBound(nBy, 1) + 1) * (UBound(nBy, 2) + 1) *3
For y = 0 To u
Hm(y) = Hmj(y) / t
Next
Function = t
End Function