harris 最常用作特征检测算法。

第一个文件harris.py

<pre name="code" class="python">from scipy.ndimage import filters
from numpy import *
from pylab import *
def compute_harris_response(im,sigma=3):
imx=zeros(im.shape)#计算导数
filters.gaussian_filter(im,(sigma,sigma),(0,1),imx)
imy=zeros(im.shape)
filters.gaussian_filter(im,(sigma,sigma),(1,0),imy)
Wxx=filters.gaussian_filter(imx*imx,sigma)
#计算harris矩阵分量
Wxy=filters.gaussian_filter(imx*imy,sigma)
Wyy=filters.gaussian_filter(imy*imy,sigma)
Wdet=Wxx*Wyy-Wxy**2 #计算矩阵的特征值和迹
Wtr=Wxx+Wyy
return Wdet/Wtr
def get_harris_points(harrisim,min_dist=10,threshold=0.1):
conner_threshold=harrisim.max()*threshold
harrisim_t=(harrisim>conner_threshold)*1 coords=array(harrisim_t.nonzero()).T
candidate_values=[harrisim[c[0],c[1]] for c in coords]
index=argsort(candidate_values)
allowed_locations=zeros(harrisim.shape)
allowed_locations[min_dist:-min_dist,min_dist:-min_dist]=1
filtered_coords=[]
for i in index:
if allowed_locations[coords[i,0],coords[i,1]]==1:
filtered_coords.append(coords[i])
allowed_locations[(coords[i,0]-min_dist):(coords[i,0]+min_dist),(coords[i,1]-min_dist):(coords[i,1]+min_dist)]=0#此处保证min_dist*min_dist仅仅有一个harris特征点
return filtered_coords
def plot_harris_points(image,filtered_coords):
figure()
gray()
imshow(image)
plot([p[1] for p in filtered_coords],[p[0]for p in filtered_coords],'+')
axis('off')
show()

第二个文件測试算法

from PIL import Image

from numpy import *
import harris
from pylab import *
from scipy.ndimage import filters
im=array(Image.open('33.jpg').convert('L'))
harrisim=harris.compute_harris_response(im)
filtered_coords=harris.get_harris_points(harrisim)
harris.plot_harris_points(im,filtered_coords)

版权声明:本文博客原创文章,博客,未经同意,不得转载。

harris 算法python实现的更多相关文章

  1. pageRank算法 python实现

    一.什么是pagerank PageRank的Page可是认为是网页,表示网页排名,也可以认为是Larry Page(google 产品经理),因为他是这个算法的发明者之一,还是google CEO( ...

  2. 常见排序算法-Python实现

    常见排序算法-Python实现 python 排序 算法 1.二分法     python    32行 right = length-  :  ]   ):  test_list = [,,,,,, ...

  3. kmp算法python实现

    kmp算法python实现 kmp算法 kmp算法用于字符串的模式匹配,也就是找到模式字符串在目标字符串的第一次出现的位置比如abababc那么bab在其位置1处,bc在其位置5处我们首先想到的最简单 ...

  4. KMP算法-Python版

                               KMP算法-Python版 传统法: 从左到右一个个匹配,如果这个过程中有某个字符不匹配,就跳回去,将模式串向右移动一位.这有什么难的? 我们可以 ...

  5. 压缩感知重构算法之IRLS算法python实现

    压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...

  6. 压缩感知重构算法之OLS算法python实现

    压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...

  7. 压缩感知重构算法之CoSaMP算法python实现

    压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...

  8. 压缩感知重构算法之IHT算法python实现

    压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...

  9. 压缩感知重构算法之SP算法python实现

    压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...

随机推荐

  1. 为什么不要在android或者ios上直连mysql或者sqlserver之类的数据库(跳大神)

    很多同学 都有直连这些数据库的想法,假设我说了下面二个问题之后你还想直连,那我也没办法 数据库是一个服务端最重要的部分,也是最脆弱的部分,更是最敏感的部分 假设直连会造成例如以下问题 1.安全问题,你 ...

  2. Understanding responsibilities is key to good object-oriented design(转)

    对象和数据的主要差别就是对象有行为,行为可以看成责任职责(responsibilities以下简称职责)的一种,理解职责是实现好的OO设计的关键.“Understanding responsibili ...

  3. C# - CSV file reader

    // ------------------------------------------------------------------------------------------------- ...

  4. CSS 初探

    Css: 指层叠样式表 (Cascading Style Sheets),它是用来进行网页风格设计的.通俗的说就是进行网页美化的,没有html依然存在,多了css 它会更好.但是没有html,css就 ...

  5. gcc #define 学习记录

    //test.c #include <stdio.h> #include <stdlib.h> //字符串化运算符 #define EXPAND(name) ({ \ prin ...

  6. 【原创】leetCodeOj --- Find Minimum in Rotated Sorted Array II 解题报告

    题目地址: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/ 题目内容: Suppose a sort ...

  7. UVA How Big Is It?

    题目例如以下: How Big Is It?  Ian's going to California, and he has to pack his things, including hiscolle ...

  8. Error Code: 1318. Incorrect number of arguments for PROCEDURE company.new_procedure; expected 2, got

    1.错误叙述性说明 20:27:34 call new_procedure(20150112) Error Code: 1318. Incorrect number of arguments for ...

  9. SQL Server 2008 新增T-SQL 简写语法

    1.定义变量时可以直接赋值 DECLARE @Id int = 5 2.Insert 语句可以一次插入多行数据 INSERT INTO StateList VALUES(@Id, 'WA'), (@I ...

  10. vpdn详细说明

     VPDN英文为Virtual Private Dial-up Networks,又称为虚拟专用拨号网,是VPN业务的一种,是基于拨号用户的虚拟专用拨号网业务. 中文名 虚拟专用拨号网业务 外文名 ...