-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenDescriptors.m
More file actions
44 lines (36 loc) · 1.64 KB
/
genDescriptors.m
File metadata and controls
44 lines (36 loc) · 1.64 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
function [ final_out ] = genDescriptors(img1_path, img2_path, label, path)
%{
Author : Vaibhav Malpani
Face Verification using SIFT features in SVM classifier
Generates SIFT features corresponding to (x,y) coordinates mentioned
in x_all and y_all.
Parameters:
img1_path - filename/filename.jpg
img2_path - filename/filename.jpg
path - path of the dataset (append img1_path or img2_path to get file)
label - class label for each pair
final_out(1) - matrix with the first column corresponding to the class label
final_out(2:end) - features generated by SIFT
%}
% points of interest
x_all = [90, 101,116, 140,150,160, 99,103,115, 142,148,158, 126,114,124,138, 108,126,127,145, 122,130, 108,160,180, 105,127,148, 113,140];
y_all = [107,105,106, 108,106,107, 115,113,115, 113,114,115, 117,142,140,141, 162,160,165,161, 182,52, 60,54,70, 152,145,150, 175,184];
% window size
% siftsize = 32;
siftsize = 24;
scale_sift(1:size(x_all,2)) = siftsize/12;
full_file_path1 = strcat(path,'/',img1_path);
full_file_path2 = strcat(path,'/',img2_path);
% generate SIFT features for im1
[im1, map1] = imread(full_file_path1);
img1 = single(im1)./ 255;
frames = [x_all; y_all; scale_sift; zeros(1,size(x_all,2))];
[f1_img1, d1_img1] = vl_sift(img1, 'frames', frames);
% generate SIFT features for im2
[im2, map2] = imread(full_file_path2);
img2 = single(im2)./ 255;
[f1_img2, d1_img2] = vl_sift(img2, 'frames', frames);
% generate pairwise descriptors
pair_descriptor = d1_img1(:) - d1_img2(:);
final_out = [label pair_descriptor'];
end