-
Notifications
You must be signed in to change notification settings - Fork 0
/
car2.m
72 lines (57 loc) · 1.37 KB
/
car2.m
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
%% car2(): Feautures extraction function
% This function creates a set of ideal filters and applies them to the
% input images. Aafter that, the energy is calculated for each resulting
% filtered image
% .The output is a features vector with the same size as the rings number
function features=car2(im)
%%
% Randomly select a pixel within the image range and create a new subimage
% _cort_
ima=imread(im);
[l1 l2 l3]=size(ima);
l=randi(l1-100);
r=randi(l2-100);
cort=ima((l:l+99),(r:r+99));
[b c]=spect1(cort); % Calls the _spect1()_ function
[x,y]=size(b);
n=50; % Rings number
if x>=y
h=x/n;
end
%%
% Calculate energy in horizontal spectrum rings
Eh=[];
for i=1:n/2
f=0;
g=lpfilter('ideal',x,y,h*i);
g2=1-lpfilter('ideal',x,y,h*(i-1));
fi=b.*g.*g2;
d=uint8(ifft2(fi));
e=sum(d(:));
Eh(i)=e;
% if i<=16
% figure(4),subplot(4,4,i),imshow(d),title(e);
% end
end
%%
% Calculate energy in vertical spectrum rings adn display the reconstructed
% image after the applied filter
Ev=[];
for i=1:n/2
g=lpfilter('ideal',x,y,h*i);
g2=1-lpfilter('ideal',x,y,h*(i-1));
fi=c.*g.*g2;
d=uint8(ifft2(fi));
e=sum(d(:));
% if i<=16
% figure(4),subplot(4,4,i),imshow(d),title(e);
% end
Ev(i)=e;
end
Eh=Eh/max(Eh);
Ev=Ev/max(Ev);
%%
% Features vector and output of the function
features(1:25)=Eh;
features(26:50)=Ev;
% figure,bar(features)