-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHarris.m
More file actions
87 lines (63 loc) · 1.22 KB
/
Harris.m
File metadata and controls
87 lines (63 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function Harris(J)
%Im=imread('lines2.jpeg');
[f c p]=size(J);
if p==1
Ir=J;
else
Ir=rgb2gray(J);
end
[m n]=size(Ir);
U=zeros(size(Ir));
S=zeros(size(Ir));
h=ones(3,3)/9;
Id=double(Ir);
If=imfilter(Id,h);
hx=[-0.5 0 0.5];
hy=[-0.5;0;0.5];
Ix=imfilter(If,hx);
Iy=imfilter(If,hy);
HE11=Ix.*Ix;
HE22=Iy.*Iy;
HE12=Ix.*Iy;
hg=[0 1 2 1 0;1 3 5 3 1;2 5 9 5 2;1 3 5 3 1;0 1 2 1 0];
hg=hg*(1/75);
A=imfilter(HE11,hg);
B=imfilter(HE22,hg);
C=imfilter(HE12,hg);
alfa=0.04;
Rp=A+B;
Rp1=Rp.*Rp;
Q=((A.*B)-(C.*C))-(alfa*Rp1);
th=1000;
U=Q>th;
pix=10;
for r=1:m
for c=1:n
if(U(r,c))
I1=[r-pix 1];
I2=[r+pix m];
I3=[c-pix 1];
I4=[c+pix n];
datxi=max(I1);
datxs=min(I2);
datyi=max(I3);
datys=min(I4);
Bloc=Q(datxi:1:datxs,datyi:1:datys);
MaxB=max(max(Bloc));
if(Q(r,c)==MaxB)
S(r,c)=1;
end
end
end
end
s=uint8(S);
figure
imshow(Ir)
hold on
for r=1:m
for c=1:n
if(S(r,c))
plot(c,r,'+');
end
end
end