-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutterfly.m~
More file actions
38 lines (27 loc) · 1.15 KB
/
butterfly.m~
File metadata and controls
38 lines (27 loc) · 1.15 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
function map = butterfly(tester)
frequenciesToKeep = 30;
imagedir = 'Images/ButterflyTraining';
output = zeros(50,frequenciesToKeep);
for a = 1:50;
im = imread([imagedir, sprintf('/Butterfly%1d.gif', a)]);
im = logical(im); %Convert the original intensity values into logical 1s and 0s
c = chainCode(im);
%% filter using the FT of the angles of the chaincode
angles = c(3,:)*(2*pi/8);
anglesFFT = fft(angles); %fast fourier transform
filteredFFT = anglesFFT(1:frequenciesToKeep); % Apply the filter by scalar multipliacation
% feature vector
output(a,:) = abs(filteredFFT)/100;
end
im = imread(tester);
im = logical(im); %Convert the original intensity values into logical 1s and 0s
c = chainCode(im);
angles = c(3,:)*(2*pi/8);
anglesFFT = fft(angles); %fast fourier transform
filteredFFT = anglesFFT(1:frequenciesToKeep); % Apply the filter by scalar multipliacation
training = abs(filteredFFT)/100;
themean = mean(output);
thecovariance = cov(output,1);
transposedMean = (themean)';
transposedTraining = (training)';
map = log(50/429) - 0.5*log(det(thecovariance)) - 0.5*((transposedTraining-transposedMean)'*(thecovariance^-1)*(transposedTraining-transposedMean));