zoukankan      html  css  js  c++  java
  • 数学之路(3)-机器学习(3)-机器学习算法-欧氏距离(3)

     欧氏距离可用于含有大量噪声的图像匹配,我们对下面的2个图像切片在一个图片上进行匹配。


    '

    前面我们运用了统计上的均值计算完成了少量噪声情况下的图像匹配

     

    本博客所有内容是原创,如果转载请注明来源

    http://blog.csdn.net/myhaspl/



    但如果加大噪声量

    比如下面这种情况的匹配,用简单的均值计算就无法完成


    这种情况,我们使用余弦算法完成匹配
    下面计算了余弦距离

     

    def get_EuclideanDistance(x,y):  
        myx=np.array(x)  
        myy=np.array(y)  
        return np.sqrt(np.sum((myx-myy)*(myx-myy)))  


    然后通过将2个图片切片在图像中进行匹配,匹配的相似度标准是余弦算法的结果。部分代码如下

     

    def findpic(img,findimg,h,fh,w,fw):
        minds=1e8
        mincb_h=0
        mincb_w=0
        for now_h in xrange(0,h-fh):
            for now_w in xrange(0,w-fw):
                my_img=img[now_h:now_h+fh,now_w:now_w+fw,:]
                my_findimg=findimg  
                dis=get_EuclideanDistance(my_img,my_findimg)
               ..........................................
            print ".",   
    ...........................   
        return img

    运行后,匹配效果如上图,效果还是不错的
    >>> runfile(r'K:ook_progann_picdw2.py', wdir=r'K:ook_prog')
    http://blog.csdn.net/myhaspl
    myhaspl@qq.com


    loading  ...
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
    >>> 






  • 相关阅读:
    cocos2d-x lua 学习笔记(1) -- 环境搭建
    Cocos2d-x 3.x 如何编译成安卓程序
    Cocos2d-x 3.4 初体验——安装教程
    cocos2d-x 之 CCProgressTimer
    android sdk离线安装
    在cocos2d-x-3.0 android 平台编译时提示CocosGUI.h: No such file or directory
    cocos2d_x iconv转码
    cocos2d-x发生undefined reference to `XX'异常 一劳永逸解决办法
    libjpeg.a exists or that its path is correct
    UE4插件
  • 原文地址:https://www.cnblogs.com/james1207/p/3315383.html
Copyright © 2011-2022 走看看