-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSimilarEars.m
54 lines (45 loc) · 1.65 KB
/
getSimilarEars.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
function simIndex = getSimilarEars(leftRef, rightRef)
% GETSIMILAREARS Get similar ears from scanned ear list
% simIndex = getSimilarEars(leftRef, rightRef)
% leftRef = left reference image
% rightRef = right reference image
% 1. Get top N ssim() results between leftRef and leftEarScans
% 2. Get top N ssim() results between rightRef and rightEarScans
% 3. Get the intersection of 1 and 2
% 4. If no intersection, get Top 2 from both
% N here is set at 5 (Top 5)
N = 5;
% Load ear_scans.mat
load ear_scans.mat ear_scans
% Get similarity index of scanned image
% with respect to reference image LEFT
for j=1:length(ear_scans.left)
if ~isempty(cell2mat(ear_scans.left(j)))
f = cell2mat(ear_scans.left(j));
g = ssim(f,leftRef);
lrank(j) = g;
end
end
% Get Top 5 LEFT
[~,topLeft] = maxk(lrank,N)
% Get similarity index of scanned image
% with respect to reference image RIGHT
for j=1:length(ear_scans.right)
if ~isempty(cell2mat(ear_scans.right(j)))
f = cell2mat(ear_scans.right(j));
g = ssim(f,rightRef);
rrank(j) = g;
end
end
% Get Top 5 RIGHT
[~,topRight] = maxk(rrank,N)
% Get the Intersection
simIndex = intersect(topLeft, topRight);
% If no intersection then choose 2 each from Left and Right
if isempty(simIndex)
disp('No intersection found, getting nearest scans.');
simIndex = [topLeft(1:2) topRight(1:2)];
end
% Display number of similar ears found
fprintf('getSimilarEars | Found: %d match/es\n',length(simIndex));
end