-
Notifications
You must be signed in to change notification settings - Fork 0
/
DQImage.h
207 lines (166 loc) · 6.04 KB
/
DQImage.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* DQImage.h
*
* Created on: Apr 6, 2014
* Author: Tim
*/
#ifndef DQIMAGE_H_
#define DQIMAGE_H_
/*****************************************************************************
****************************** I N C L U D E *******************************
*****************************************************************************/
#include <QImage>
#include <opencv2/core.hpp>
#include "DHistogram.h"
/*****************************************************************************
*
*** class DQImage
*
* This class extends QImage by adding to functionality while still allowing
* interoperability with functions taking a QImage as a parameter.
*
*****************************************************************************/
class DQImage : public QImage
{
public:
DQImage() : QImage(), m_ROI(QRect())
{
return;
}
DQImage(const QSize& Size, QImage::Format eFormat) : QImage(Size, eFormat), m_ROI(QRect())
{
return;
}
DQImage(int nWidth, int nHeight, QImage::Format eFormat) : QImage(nWidth, nHeight, eFormat), m_ROI(QRect())
{
return;
}
DQImage(uchar* pData, int nWidth, int nHeight, Format eFormat, QImageCleanupFunction CleanupFunction = nullptr,
void* pCleanupInfo = nullptr) :
QImage(pData, nWidth, nHeight, eFormat, CleanupFunction, pCleanupInfo), m_ROI(QRect())
{
return;
}
DQImage(const uchar* pData, int nWidth, int nHeight, Format eFormat,
QImageCleanupFunction CleanupFunction = nullptr, void* pCleanupInfo = nullptr) :
QImage(pData, nWidth, nHeight, eFormat, CleanupFunction, pCleanupInfo), m_ROI(QRect())
{
return;
}
DQImage(uchar* pData, int nWidth, int nHeight, int nBytesPerLine, Format eFormat,
QImageCleanupFunction CleanupFunction = nullptr, void* pCleanupInfo = nullptr) :
QImage(pData, nWidth, nHeight, nBytesPerLine, eFormat, CleanupFunction, pCleanupInfo), m_ROI(QRect())
{
return;
}
DQImage(const uchar* pDdata, int nWidth, int nHeight, int nBytesPerLine, Format eFormat,
QImageCleanupFunction CleanupFunction = nullptr, void* pCleanupInfo = nullptr) :
QImage(pDdata, nWidth, nHeight, nBytesPerLine, eFormat, CleanupFunction, pCleanupInfo), m_ROI(QRect())
{
return;
}
explicit DQImage(const char** pXPM) : QImage(pXPM), m_ROI(QRect())
{
return;
}
DQImage(const QString& strFileName, const char* pFormat = nullptr) : QImage(strFileName, pFormat), m_ROI(QRect())
{
return;
}
DQImage(const DQImage& src) : QImage(src), m_ROI(src.m_ROI)
{
return;
}
DQImage(const QImage& src) : QImage(src), m_ROI(QRect())
{
return;
}
DQImage(DQImage&& Other) : QImage(Other), m_ROI(Other.m_ROI)
{
return;
}
~DQImage() = default;
DQImage& operator=(const DQImage& rhs)
{
if (this != &rhs)
{
QImage::operator=(rhs);
m_ROI = rhs.m_ROI;
} // end if
return (*this);
}
DQImage& operator=(const QImage& rhs)
{
if (this != &rhs)
{
QImage::operator=(rhs);
m_ROI = QRect();
} // end if
return (*this);
}
DQImage& operator=(const DQImage&& rhs)
{
if (this != &rhs)
{
QImage::operator=(rhs);
m_ROI = rhs.m_ROI;
} // end if
return (*this);
}
DQImage& operator=(const QImage&& rhs)
{
if (this != &rhs)
{
QImage::operator=(rhs);
m_ROI = QRect();
} // end if
return (*this);
}
// Deep copy
DQImage copy(const QRect& Rect = QRect()) const
{
DQImage Image(QImage::copy(Rect));
Image.m_ROI = m_ROI;
return (Image);
}
// Create a new indexed 8 bit image from a single color plane
DQImage RedChannel() const;
DQImage GreenChannel() const;
DQImage BlueChannel() const;
// Create a new inexed 8 bit image from the color planes
// in HSV. Hue is scaled to the range 0-255 from 0-359.
DQImage HSVHue8Channel(bool bRed = true, bool bGreen = false, bool bBlue = true) const;
DQImage HSVSaturationChannel(bool bRed = false, bool bGreen = true, bool bBlue = true) const;
DQImage HSVValueChannel(bool bRed = true, bool bGreen = true, bool bBlue = true) const;
// Create a new inexed 8 bit image from the color planes
// in HSL. Hue is scaled to the range 0-255 from 0-359.
DQImage HSLHue8Channel(bool bRed = true, bool bGreen = false, bool bBlue = true) const;
DQImage HSLSaturationChannel(bool bRed = false, bool bGreen = true, bool bBlue = true) const;
DQImage HSLLightnessChannel(bool bRed = true, bool bGreen = true, bool bBlue = true) const;
// Set up a linear color table for 8 bit indexed images
bool SetLinearColorTable(bool bRed, bool bGreen, bool bBlue);
// Create a new grayscale image from this image
DQImage Gray() const;
// Region of interest functions
const QRect& GetROI() const
{
return (m_ROI);
}
void ClearROI()
{
m_ROI = QRect();
return;
}
void SetROI(const QRect& ROI)
{
m_ROI = ROI;
return;
}
// Get the histogram of single plane images
bool CalcHistogram(DHistogram& Histogram, bool bUseROI = true) const;
protected:
// Add a Region of Interest rectangle
QRect m_ROI;
private:
}; // end of class DQImage
#endif /* DQIMAGE_H_ */