当前位置:网站首页>[Chapter 17 corner feature detection based on Harris -- actual combat of MATLAB machine learning project]

[Chapter 17 corner feature detection based on Harris -- actual combat of MATLAB machine learning project]

2022-06-22 02:05:00 Haibao 7

Deep learning machine learning image processing matlab Source code – be based on Harris A case study of corner feature detection based on – Program Source code download source
 Insert picture description here
Corner detection subfunction :

function varargout=harris(I,k,q,h)
narginchk(0,4);
nargoutchk(0,2);
if nargin<1
    I=checkerboard(50,2,2);
end
if nargin<2
    k=0.04;
end
if nargin<3
    q=0.01;
end
if nargin<3
    h=fspecial('gaussian',[5 5],1.5);
end
fx=[-2,-1,0,1,2];
Ix=filter2(fx,I);
fy=[-2,-1,0,1,2]';
Iy=filter2(fy,I);
Ix2=filter2(h,Ix.^2);
Iy2=filter2(h,Iy.^2);
Ixy=filter2(h,Ix.*Iy);
rfcn=@(a,b,c)(a*b-c^2)-k*(a+b)^2;
R=arrayfun(rfcn,Ix2,Iy2,Ixy);
R(R < q*max(R(:)))=0;
[xp,yp]=find(imregionalmax(R,8));
if nargout==0
    subplot(121)
    imshow(I);
    hold on;
    plot(xp,yp,'ro');
    title(' Write your own HARRIS Algorithm ')
    subplot(122)
    cp=corner(I);
    imshow(I)
    hold on
    plot(cp(:,1),cp(:,2),'ro');
    title('MATLAB Bring their own CORNER function ')
elseif nargout==1
    varargout={
    [xp,yp]};
elseif nargout==2
    varargout={
    xp,yp};
end

The main function :

clc; clear all; close all;
I = checkerboard(50,3,3);
h = fspecial('gaussian',[5 5],2);
harris(I,0.05,0.01,h);

 Insert picture description here
This algorithm is relatively basic – There are also many descriptions and uses on the Internet .
Harris Corner detection algorithm is divided into the following three steps :
1、 When the window ( Local areas ) Simultaneous direction x ( level ) and y( vertical ) When moving in both directions , Calculate the change of pixel value inside the window ;
2、 For each window , The corresponding corner response function is calculated ;
3、 Then the function is threshold processed , If , Indicates that the window corresponds to a corner feature .

 Insert picture description here
Many are in openCV The use of , Preprocessing module combined with machine learning , wait . stay matlab Just test it out . The same principle , It's just that the platform is different . There is no unique innovation .

原网站

版权声明
本文为[Haibao 7]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220101377680.html