-
Notifications
You must be signed in to change notification settings - Fork 0
/
classifying_entire_dataset.m
51 lines (46 loc) · 1.46 KB
/
classifying_entire_dataset.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
clc
clear
close all
run('D:/Softwares/vlfeat-0.9.20/toolbox/vl_setup');
plane_source = dir('D:\Mandeep\Summer\BTP\Tracking\Hog\positives_test_data\');
count = length(plane_source);
plane_source = 'D:\Mandeep\Summer\BTP\Tracking\Hog\positives_test_data\';
load('weights.mat');
load('offsets.mat');
load('vocabulary.mat');
false_positive = 0;
images_tried = 0;
for counter = 1:count-2
num2str(counter);
filename = strcat(plane_source,num2str(counter),'.jpg');
c_i = imread(filename);
features = extract_features(c_i,vocabulary);
[plane,score] = classify(features,weights,offsets);
if(plane)
false_positive = false_positive + 1;
end
end
function [features] = extract_features(img,vocabulary)
img = im2single(rgb2gray(img));
vocab_size = size(vocabulary, 1);
[~, features] = vl_dsift(img, 'Fast', 'Step', 4);
features = single(features);
[indices] = knnsearch(vocabulary, features');
imhist=histc(indices, 1:vocab_size);
imhist_norm=imhist./numel(imhist);
features = imhist_norm';
end
function [plane,score] = classify(features,weights,offsets)
training_score = [];
for i = 1:2
training_score = [training_score; weights{i}'*features' + offsets{i}];
end
[~,label_indices] = max(training_score);
if (label_indices == 2)
score = training_score(label_indices);
plane = 1;
else
plane = 0;
score = 0;
end
end