harris 算法python实现
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实现的更多相关文章
- pageRank算法 python实现
一.什么是pagerank PageRank的Page可是认为是网页,表示网页排名,也可以认为是Larry Page(google 产品经理),因为他是这个算法的发明者之一,还是google CEO( ...
- 常见排序算法-Python实现
常见排序算法-Python实现 python 排序 算法 1.二分法 python 32行 right = length- : ] ): test_list = [,,,,,, ...
- kmp算法python实现
kmp算法python实现 kmp算法 kmp算法用于字符串的模式匹配,也就是找到模式字符串在目标字符串的第一次出现的位置比如abababc那么bab在其位置1处,bc在其位置5处我们首先想到的最简单 ...
- KMP算法-Python版
KMP算法-Python版 传统法: 从左到右一个个匹配,如果这个过程中有某个字符不匹配,就跳回去,将模式串向右移动一位.这有什么难的? 我们可以 ...
- 压缩感知重构算法之IRLS算法python实现
压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...
- 压缩感知重构算法之OLS算法python实现
压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...
- 压缩感知重构算法之CoSaMP算法python实现
压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...
- 压缩感知重构算法之IHT算法python实现
压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...
- 压缩感知重构算法之SP算法python实现
压缩感知重构算法之OMP算法python实现 压缩感知重构算法之CoSaMP算法python实现 压缩感知重构算法之SP算法python实现 压缩感知重构算法之IHT算法python实现 压缩感知重构 ...
随机推荐
- DrectX11学习笔记Texture2D有关
///////////////////////////////////////////////////////////////////////////////////// 有时候....有时候.... ...
- CentOS下tmux安装与使用
tmux介绍: tmux它是BSDScreen替代品,相对于Screen,它更加先进:支持屏幕切分,并且具备丰富的命令行參数,使其能够灵活.动态的进行各种布局和操作.它能够做到一条命令就启动起来(强大 ...
- Windows 8 应用开发 - 本地数据存储
原文:Windows 8 应用开发 - 本地数据存储 在应用中通常会遇到用户主动或被动存储信息的情况,当应用关闭后这些数据仍然会存储在本地设备上,用户下次重新激活应用时会自动加载这些数据.下 ...
- Java 并发专题 : CyclicBarrier 打造一个安全的门禁系统
继续并发专题~ 这次介绍CyclicBarrier:看一眼API的注释: /** * A synchronization aid that allows a set of threads to all ...
- JAVA网络编程Socket常见问题 【长连接专题】
一. 网络程序运行过程中的常见异常及处理 第1个异常是 java.net.BindException:Address already in use: JVM_Bind. 该异常发生在服务器端进行new ...
- 【NO.3】 c program to caculate and display sum of two matrix
source code: #include "stdafx.h" /* display sum of two matrix*/ int _tmain(int argc, _TCHA ...
- (二十)unity4.6得知Ugui中国文献-------另外-InputModules
大家好.我是太阳广东. 转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unitym ...
- CenOS下安装jdk
1. 安装JDK1.7.0 下载完成后在取得root权限后执行: [root@sea sea]# sudo rpm -ivh /目录/jdk-7-linux-x64.rpm 执行结果: Prepari ...
- Xcode 5.1.1 与 Xcode 6.0.1 共存
Xcode 5.1.1 (下面简称Xcode5)和Xcode 6.0.1(下面简称Xcode6)都是正式版本号.其应用程序文件名称都是"Xcode".假设通过AppStore升级或 ...
- UIScrollViewA都PI得知。
//1.设定滚定条的样式 typedef NS_ENUM(NSInteger, UIScrollViewIndicatorStyle) { UIScrollViewIndicatorStyleDefa ...