-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLabeling.h
52 lines (44 loc) · 1.28 KB
/
Labeling.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
/*!
* @file Labeling.h
* @author Yasutomo Kawanishi
* @date Last Change:02-Jun-2012.
* */
#ifndef __LABELING_H_
#define __LABELING_H_
#include <cv.h>
#include <vector>
#define LABELING_CONNECT_8 0
#define LABELING_CONNECT_4 1
/**
* @class Labeling
* @note '0' shows the background pixel
* ordered by region size if sorting is enabled
* ordered by finding if sorting is disalbed
* */
class Labeling{
public:
Labeling();
~Labeling();
Labeling(const Labeling& other);
Labeling& operator=(const Labeling& other);
unsigned short operator()(const cv::Mat& src, int connect=LABELING_CONNECT_8);
cv::Mat getLabel()const; // ( CV_16UC1 j
unsigned short getRegionSize(unsigned short i)const;
private:
inline unsigned short _checkNeighbor();
inline unsigned short _compaction();
inline unsigned short _compaction(unsigned short i);
inline void _compaction2();
inline void _sort(unsigned short num);
unsigned short neighbor[4];
std::vector<unsigned short> labeltable;
std::vector<unsigned short> regionsize;
cv::Mat label;
bool isLabeled;
struct _PairSort{
public:
bool operator()(const std::pair<unsigned short,unsigned short>& x,const std::pair<unsigned short,unsigned short>& y)const
{return x.second>y.second;}
};
};
#endif