Repository navigation
Expand file tree
/
Copy pathCompare.cpp
More file actions
106 lines (76 loc) · 2.49 KB
/
Copy pathCompare.cpp
File metadata and controls
106 lines (76 loc) · 2.49 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "Compare.h"
#include <iterator>
#include <math.h>
//the constructor will call all of the methodw
Compare::Compare(std::vector<Pixel> iris1,std::vector<Pixel> iris2) {
this->iris1=iris1;
this->iris2=iris2;
equalize_Arrays();
correct_Brightness_Differences();
color_differences = find_Pattern_Differences();
find_Percent_Similarity();
is_same_person();
}
void Compare::equalize_Arrays() {
std::vector<Pixel> bigger_Array;
std::vector<Pixel> smaller_Array;
std::cout<< "iris size1 = " << iris1.size() << std::endl;
std::cout<< "iris size2 = " << iris2.size() << std::endl;
if (iris1.size() > iris2.size()) {
bigger_Array = iris1;
smaller_Array = iris2;
}
else {
bigger_Array = iris2;
smaller_Array = iris1;
}
int diff = bigger_Array.size() - smaller_Array.size();
int jump_size = bigger_Array.size() / diff;
for (int i = 0; i < bigger_Array.size(); i++) {
if (i % jump_size == 0) {
bigger_Array.erase(bigger_Array.begin() + i);
}
}
if (iris1.size() > iris2.size()) {
iris1 = bigger_Array;
}
else {
iris2 = bigger_Array;
}
return;
}
void Compare::correct_Brightness_Differences() {
return;
}
//returns an inte difference for each pixel in the arrays
std::vector<int> Compare::find_Pattern_Differences() {
std::vector<int> result;
for (int i = 0; i < iris1.size() &&i< iris2.size(); i++) {
int diff_1, diff_2, diff_3;
diff_1 = abs(iris1[i].getRed() - iris2[i].getRed());
diff_2 = abs(iris1[i].getGreen() - iris2[i].getGreen());
diff_3 = abs(iris1[i].getBlue() - iris2[i].getBlue());
std::cout<< " diff1 = " << diff_1 << " diff2 = " << diff_2 << " diff3 = " << diff_3 << std::endl;
result.push_back(diff_1+diff_2+diff_3);
}
return result;
}
void Compare::find_Percent_Similarity() {
const double MAX_DIFF_VALUE = 3 * 252;
double result;
std::vector<double> percent_color_diff;
for (int i = 0; i < color_differences.size() ; i++) {
percent_color_diff.push_back((color_differences[i]/MAX_DIFF_VALUE));
result += percent_color_diff[i];
}
percent_color_difference = result/percent_color_diff.size();
return;
}
bool Compare::is_same_person() {
//10% is arbitrary, we can change it depending on how our tests go
if (percent_color_difference > 0.5 ) {
is_same = true;
}
else is_same = false;
return is_same;
}