韩漫免费漫画在线观看方法,《好好疼爱里面》免费看,年轻漂亮的女士护士内衣,妈妈醉酒后把我当爸爸电视剧

文章 > Python基础教程 > python中Harris角点检测

python中Harris角点检测

Python Harris

头像

小妮浅浅

2021-08-28 09:21:543978浏览 · 0收藏 · 0评论

基本思想

1、选择在图像上任意方向的固定窗口进行滑动,如果灰度变化较大,则认为该窗口内部存在角点。

2、步骤,读图并将其转换为灰度图。估计响应函数。根据响应值选择角度。画出原始图上的检测角点。

实例

from pylab import *
from numpy import *
from scipy.ndimage import filters
 
 
def compute_harris_response(im,sigma=3):
    """ Compute the Harris corner detector response function
        for each pixel in a graylevel image. """
    
    # derivatives
    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)
    
    # compute components of the Harris matrix
    Wxx = filters.gaussian_filter(imx*imx,sigma)
    Wxy = filters.gaussian_filter(imx*imy,sigma)
    Wyy = filters.gaussian_filter(imy*imy,sigma)
    
    # determinant and trace
    Wdet = Wxx*Wyy - Wxy**2
    Wtr = Wxx + Wyy
    
    return Wdet / Wtr
   
    
def get_harris_points(harrisim,min_dist=10,threshold=0.1):
    """ Return corners from a Harris response image
        min_dist is the minimum number of pixels separating
        corners and image boundary. """
    
    # find top corner candidates above a threshold
    corner_threshold = harrisim.max() * threshold
    harrisim_t = (harrisim > corner_threshold) * 1
    
    # get coordinates of candidates
    coords = array(harrisim_t.nonzero()).T
    
    # ...and their values
    candidate_values = [harrisim[c[0],c[1]] for c in coords]
    
    # sort candidates (reverse to get descending order)
    index = argsort(candidate_values)[::-1]
    
    # store allowed point locations in array
    allowed_locations = zeros(harrisim.shape)
    allowed_locations[min_dist:-min_dist,min_dist:-min_dist] = 1
    
    # select the best points taking min_distance into account
    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
    
    return filtered_coords
    
    
def plot_harris_points(image,filtered_coords):
    """ Plots corners found in image. """
    
    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
import Harris_Detector
from pylab import *
from scipy.ndimage import filters
 
# filename
im = array(Image.open(r"  ").convert('L'))
harrisim=Harris_Detector.compute_harris_response(im)
filtered_coords=Harris_Detector.get_harris_points(harrisim)
Harris_Detector.plot_harris_points(im,filtered_coords)

以上就是python中Harris角点检测的方法,希望对大家有所帮助。更多Python学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

白天像教授晚上像野兽| 免费观看已满十八岁电视剧国外| 狗和女人戴避孕套会传染吗| 《交换做爰》在线观看| 《老板送醉酒丈夫回家》| 《黏糊糊的你》动漫免费观看| 人马杂配MV的视频在哪里看| WWW.1688.COM麻豆.| 日日精进久久为功的下一句是| 《魅魔之耻》1~4集免费看| 《办公室高潮秘书2》| 日韩精品| 老公说我越来越骚的心理| 视频| 老师脱了内裤让我进去| 美国禁忌| 插不进去怎么办辅助用具| 日本一姐RAPPER太多| 女人被男人进入后的心理变化 | 把她日出水了好紧大爽了视频| 拔萝卜高清免费大全电视剧| 母与子免费观看大全电视剧| 一家乱战1-13集大| 玉女献身台湾1988版主演是谁| 《黏糊糊的你》动漫免费观看| 妈妈的朋友4| 欧美大妈LOGO大全及价格图| 双人床上剧烈运动会怎么消除 | 在桌下含她的花蒂和舌头漫画| 啊…快……用力啊小能视频| 太粗太大弄死我了L毛片| 日本插槽X8X8与X8X8的区..| 小妈爱上继子免费观看电视剧| 性做爰A片春欲| 寡妇春性饥渴1-4| 妈妈在家穿超薄内裤的注意事项| 第一章破外女初尝云雨| 戴着小玩具练瑜伽| 美女被捆绑绳子穿过下体 勒胸| BOBO浏览器(海外版)| 人犬兽人在线观看免费完整