-
Notifications
You must be signed in to change notification settings - Fork 0
/
EDColor.h
107 lines (83 loc) · 3.31 KB
/
EDColor.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
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
99
100
101
102
103
104
105
106
107
/**************************************************************************************************************
* Color Edge Drawing (ED) and Color Edge Drawing Parameter Free (EDPF) source codes.
* Copyright (c) 2017, Cuneyt Akinlar & Cihan Topal
* E-mails of the authors: [email protected], [email protected]
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* By using this library you are implicitly assumed to have accepted all of the above statements,
* and accept to cite the following papers:
*
* [1] C. Topal and C. Akinlar, “Edge Drawing: A Combined Real-Time Edge and Segment Detector,?* Journal of Visual Communication and Image Representation, 23(6), 862-872, doi:10.1016/j.jvcir.2012.05.004 (
*
* [2] C. Akinlar and C. Topal, “EDPF: A Real-time Parameter-free Edge Segment Detector with a False Detection Con
* International Journal of Pattern Recognition and Artificial Intelligence, 26(1), doi:10.1142/S0218001412550
*
* [3] C. Akinlar, C. Topal, "ColorED: Color Edge and Segment Detection by Edge Drawing (ED),"
* submitted to the Journal of Visual Communication and Image Representation (2017).
**************************************************************************************************************/
#ifndef _EDColor_
#define _EDColor_
#include <opencv2/opencv.hpp>
// Look up table size for fast color space conversion
#define LUT_SIZE (1024*4096)
// Special defines
#define EDGE_VERTICAL 1
#define EDGE_HORIZONTAL 2
#define EDGE_45 3
#define EDGE_135 4
#define MAX_GRAD_VALUE 128*256
#define EPSILON 1.0
#define MIN_PATH_LEN 10
class EDColor {
public:
EDColor(cv::Mat srcImage, int gradThresh = 20, int anchor_thresh = 4, double sigma = 1.5, bool validateSegments=false);
cv::Mat getEdgeImage();
std::vector<std::vector<cv::Point>> getSegments();
int getSegmentNo();
int getWidth();
int getHeight();
cv::Mat inputImage;
private:
uchar *L_Img;
uchar *a_Img;
uchar *b_Img;
uchar *smooth_L;
uchar *smooth_a;
uchar *smooth_b;
uchar *dirImg;
short *gradImg;
cv::Mat edgeImage;
uchar *edgeImg;
const uchar *blueImg;
const uchar *greenImg;
const uchar *redImg;
int width;
int height;
double divForTestSegment;
double *H;
int np;
int segmentNo;
std::vector<std::vector<cv::Point>> segments;
static double LUT1[LUT_SIZE + 1];
static double LUT2[LUT_SIZE + 1];
static bool LUT_Initialized;
void MyRGB2LabFast();
void ComputeGradientMapByDiZenzo();
void smoothChannel(uchar *src, uchar *smooth, double sigma);
void validateEdgeSegments();
void testSegment(int i, int index1, int index2);
void extractNewSegments();
double NFA(double prob, int len);
static void fixEdgeSegments(std::vector<std::vector<cv::Point>> map, int noPixels);
static void InitColorEDLib();
};
#endif // ! _EDColor_