35 #pragma warning(push, 0) // no warnings from includes 36 #include <QSharedPointer> 43 #include <opencv2/core.hpp> 46 #pragma warning (disable: 4251) // inlined Qt functions in dll interface 49 #ifdef DLL_CORE_EXPORT 50 #define DllCoreExport Q_DECL_EXPORT 52 #define DllCoreExport Q_DECL_IMPORT 65 Histogram(
const cv::Mat& values = cv::Mat());
66 Histogram(
double minVal,
double maxVal,
int numBins = 256);
68 cv::Mat draw(
const QPen& pen = QPen(),
const QColor& bgCol = QColor(255, 255, 255));
69 void draw(QPainter& p,
const Rect& r)
const;
74 double maxBin()
const;
75 int maxBinIdx()
const;
76 double minBin()
const;
78 int binIdx(
double val)
const;
79 double value(
int binIdx)
const;
81 void add(
double val,
double weight = 1.0);
83 template <
typename Num>
86 double minV = 0, maxV = 0;
87 cv::minMaxLoc(data, &minV, &maxV);
90 qWarning() <<
"min == max that's not good for creating a histogram - aborting";
95 float* hmp = h.
hist().ptr<
float>();
97 for (
int rIdx = 0; rIdx < data.rows; rIdx++) {
99 const Num* ptr = data.ptr<Num>(rIdx);
101 for (
int cIdx = 0; cIdx < data.cols; cIdx++) {
105 int bin = h.
binIdx(ptr[cIdx]);
114 void draw(QPainter& p)
const;
115 double transformX(
double val,
const Rect& r)
const;
116 double transformY(
double val,
double minV,
double maxV,
const Rect& r)
const;
136 DllCoreExport bool save(
const QImage& img,
const QString& savePath,
int compression = -1);
137 DllCoreExport bool save(
const cv::Mat& img,
const QString& savePath,
int compression = -1);
154 template <
typename numFmt>
155 QString
printMat(
const cv::Mat& src,
const QString varName) {
157 QString msg = varName;
162 for (
int rIdx = 0; rIdx < src.rows; rIdx++) {
164 const numFmt* srcPtr = src.ptr<numFmt>(rIdx);
166 for (
int cIdx = 0; cIdx < src.cols; cIdx++, cnt++) {
169 msg.append(QString::number(srcPtr[cIdx]));
170 msg.append( (cIdx < src.cols - 1) ?
" " :
"; " );
172 if (cnt % 7 == 0 && cnt > 0)
DllCoreExport cv::Mat qVector2Mat(const QVector< float > &data)
Definition: Image.cpp:141
int binIdx(double val) const
Definition: Image.cpp:575
cv::Mat hist() const
Definition: Image.cpp:546
DllCoreExport QImage mat2QImage(const cv::Mat &img, bool toRGB=false)
Converts a cv::Mat to QImage.
Definition: Image.cpp:106
static Histogram fromData(const cv::Mat &data, int numBins=256)
Definition: Image.h:84
#define DllCoreExport
Definition: Image.h:52
DllCoreExport bool save(const cv::Mat &img, const QString &savePath, int compression=-1)
Saves the specified cv::Mat img.
Definition: Image.cpp:218
DllCoreExport QString printImage(const cv::Mat &img, const QString name)
Prints the image as a string formatted according Matlab.
Definition: Image.cpp:313
DllCoreExport bool alphaChannelUsed(const QImage &img)
Checks if the alpha channel is used.
Definition: Image.cpp:234
DllCoreExport void imageInfo(const cv::Mat &img, const QString name)
Prints the basic image information.
Definition: Image.cpp:263
DllCoreExport bool writeMat(const cv::Mat &img, const QString &filePath, bool compress=true)
Definition: Image.cpp:366
QString printMat(const cv::Mat &src, const QString varName)
Prints the values of a cv::Mat to copy it to Matlab.
Definition: Image.h:155
DllCoreExport QImage load(const QString &path, bool *ok=0)
Definition: Image.cpp:152
DllCoreExport QJsonObject matToJson(const cv::Mat &img, bool compress=true)
Definition: Image.cpp:333
Definition: Algorithms.cpp:45
DllCoreExport cv::Mat qImage2Mat(const QImage &img)
Converts a QImage to a cv::Mat.
Definition: Image.cpp:60
cv::Mat mHist
Definition: Image.h:118
DllCoreExport cv::Mat jsonToMat(const QJsonObject &jo, const QString &filePath="")
Definition: Image.cpp:399
DllCoreExport QJsonObject matToJsonExtern(const cv::Mat &img, const QString &fileName, bool compress=true)
Definition: Image.cpp:353