博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Harris算子进行角点检测算法
阅读量:6469 次
发布时间:2019-06-23

本文共 2825 字,大约阅读时间需要 9 分钟。

function points = kp_harris(im)    % Extract keypoints using Harris algorithm (with an improvement    % version)        % INPUT    % =====    % im     : the graylevel image    %    % OUTPUT    % ======    % points : the interest points extracted    %    % REFERENCES    % ==========    % C.G. Harris and M.J. Stephens. "A combined corner and edge detector",    % Proceedings Fourth Alvey Vision Conference, Manchester.    % pp 147-151, 1988.    %    % Alison Noble, "Descriptions of Image Surfaces", PhD thesis, Department    % of Engineering Science, Oxford University 1989, p45.    %    % C. Schmid, R. Mohrand and C. Bauckhage, "d",    % Int. Journal of Computer Vision, 37(2), 151-172, 2000.    %    % EXAMPLE    % =======    % points = kp_harris(im)     % only luminance value    %size(im)    im = double(im(:,:,1));    sigma = 1.5;        % derivative masks    s_D = 0.7*sigma;    x  = -round(3*s_D):round(3*s_D);        dx = x .* exp(-x.*x/(2*s_D*s_D)) ./ (s_D*s_D*s_D*sqrt(2*pi));    dy = dx';        % image derivatives    Ix = conv2(im, dx, 'same');    Iy = conv2(im, dy, 'same');     % sum of the Auto-correlation matrix    s_I = sigma;    g = fspecial('gaussian',max(1,fix(6*s_I+1)), s_I);    Ix2 = conv2(Ix.^2, g, 'same'); % Smoothed squared image derivatives    Iy2 = conv2(Iy.^2, g, 'same');    Ixy = conv2(Ix.*Iy, g, 'same');     % interest point response    cim = (Ix2.*Iy2 - Ixy.^2)./(Ix2 + Iy2 + eps);                    % find local maxima on 3x3 neighborgood    [r,c,max_local] = findLocalMaximum(cim,3*s_I);     % set threshold 1% of the maximum value    %t = 0.01*max(max_local(:));     t = 0.6*max(max_local(:)); %door.jpg    %t = 0.48*max(max_local(:));  %sunflower.jpg        % find local maxima greater than threshold    [r,c] = find(max_local>=t);     % build interest points    points = [r,c];end

  

function [row,col,max_local] = findLocalMaximum(val,radius)    % Determine the local maximum of a given value    %    %    % INPUT    % =====    % val    : the NxM matrix containing values    % radius : the radius of the neighborhood    %    % OUTPUT    % ======    % row       : the row position of the local maxima    % col       : the column position of the local maxima    % max_local : the NxM matrix containing values of val on unique local maximum    %    % EXAMPLE    % =======    % [l,c,m] = findLocalMaximum(img,radius);        % FIND UNIQUE LOCAL MAXIMA USING FILTERING (FAST)    mask  = fspecial('disk',radius)>0;    nb    = sum(mask(:));    highest          = ordfilt2(val, nb, mask);    second_highest   = ordfilt2(val, nb-1, mask);    index            = highest==val & highest~=second_highest;    max_local        = zeros(size(val));    max_local(index) = val(index);    [row,col]        = find(index==1);end

结果:

转载于:https://www.cnblogs.com/CBDoctor/archive/2013/04/13/3019070.html

你可能感兴趣的文章
graph-tool文档(一)- 快速开始使用Graph-tool - 2.属性映射、图的IO和Price网络
查看>>
graph-tool 练习
查看>>
easyui treegrid逐步加载
查看>>
GraphicsLab Project之辉光(Glare,Glow)效果 【转】
查看>>
<转>Python: __init__.py 用法
查看>>
Linux Curl命令
查看>>
046 SparlSQL中的函数
查看>>
Zookeeper 的 Lua 绑定(二)
查看>>
-27979 LoadRunner 错误27979 找不到请求表单 Action.c(73): Error -27979: Requested form not found...
查看>>
[LeetCode] Minimum Depth of Binary Tree
查看>>
,net运行框架
查看>>
Java 中 Emoji 的正则表达式
查看>>
Mixin Network第一届开发者大赛作品介绍- dodice, diceos和Fox.one luckycoin
查看>>
安卓Glide(4.7.1)使用笔记 01 - 引入项目
查看>>
AndroidNote
查看>>
中金易云:为出版社找到下一本《解忧杂货店》
查看>>
Flex布局
查看>>
Material Design之 AppbarLayout 开发实践总结
查看>>
Android中的SurfaceView详解
查看>>
Flutter之MaterialApp使用详解
查看>>