-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageinfo.cpp
More file actions
34 lines (31 loc) · 1.14 KB
/
Copy pathimageinfo.cpp
File metadata and controls
34 lines (31 loc) · 1.14 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
#include "imageinfo.h"
#define numPartsDiff_allowed 3 // how many pixels per image pair are allowed to be different
#define numDiffPerPartAllowed 15 //how different the avereaged pixels are allowed to be
bool ImageInfo::collidesWith(ImageInfo& other){
int numPartsDiff = 0; // number of average boxes that can be different and still not collide
for(int x=0; x<9*9; x++){
if(abs(other.red[x] - this->red[x]) > numDiffPerPartAllowed){
numPartsDiff++;
if(numPartsDiff > numPartsDiff_allowed)
return false;
}else if(abs(other.green[x] - this->green[x]) > numDiffPerPartAllowed){
numPartsDiff++;
if(numPartsDiff > numPartsDiff_allowed)
return false;
}else if(abs(other.blue[x] - this->blue[x]) > numDiffPerPartAllowed){
numPartsDiff++;
if(numPartsDiff > numPartsDiff_allowed)
return false;
}
}
return true; // they do collide
}
bool ImageInfo::operator==(const ImageInfo& rhs)const{
if(fileName != rhs.fileName) return false;
if(filePath != rhs.filePath) return false;
if(knownCollisions != rhs.knownCollisions) return false;
return true;
}
bool ImageInfo::operator !=(const ImageInfo& rhs)const{
return !((*this)==rhs);
}