-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutterfly.m
More file actions
32 lines (26 loc) · 1.12 KB
/
butterfly.m
File metadata and controls
32 lines (26 loc) · 1.12 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
function map = butterfly(tester)
frequenciesToKeep = 6;
output = zeros(50,frequenciesToKeep);
for a = 1:50;
im = imread(sprintf('Images/ButterflyTraining/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/227) - 0.5*log(det(thecovariance)) - 0.5*((transposedTraining-transposedMean)'*(thecovariance^-1)*(transposedTraining-transposedMean));