-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMosaitCentroid.h
52 lines (49 loc) · 1.77 KB
/
MosaitCentroid.h
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
/**
* Mosait by Tangui Morlier
* Under GPLv3
*/
#ifndef MOSAIT_CENTROID
#define MOSAIT_CENTROID
#include "MosaitCommon.h"
#include "MosaitImg.h"
#include <vector>
#define MOSAITCENTROID_REMOVE 1
#define MOSAITCENTROID_UNFAIR 2
#define MOSAITCENTROID_KEEP 0
class MosaitCentroid
{
public:
MosaitCentroid();
MosaitCentroid(MosaitCentroid & centroid, int nb_sub_centroids, int max = 0, string out = "");
MosaitCentroid(vector<MosaitImg> & images);
MosaitCentroid(vector<MosaitImg> & vimages, int nb_sub_centroids, int max);
MosaitImg getClosestImage(MosaitImg & image, int remove_or_unfair_it = MOSAITCENTROID_REMOVE);
bool operator==(const MosaitCentroid & centroid) const;
std::ostream& dumpInStream(std::ostream& os);
friend std::ostream& operator<<(std::ostream& os, MosaitCentroid & mc);
friend istream & operator >>(istream &ins, MosaitCentroid & mc);
int getNbImages() const;
void printNbImages(string prefix = "") const;
void dumpInFile(string & file);
void split(int nb_sub_centroids, int max = 0);
static bool compareBySize(const MosaitCentroid & a, const MosaitCentroid & b) ;
// static bool compareBySubImageDistance(const MosaitCentroid & a, const MosaitCentroid & b) ;
inline static bool compareBySubImageDistance(const MosaitCentroid & a, const MosaitCentroid & b)
{
return a.virtual_img.getDistance() < b.virtual_img.getDistance();
};
int getNbCentroids() const;
private:
MosaitImg virtual_img;
vector<MosaitImg> images;
vector<MosaitCentroid> sub_centroids;
vector<MosaitCentroid>::iterator getClosestCentroid(MosaitImg & image);
void updateVirtualImage();
void addImage(MosaitImg& image);
void init(vector<MosaitImg> & images, int max = 0);
void clearImages();
bool has_sub_centroids;
int removed;
string out_file;
};
#endif