Read@CVL
GradientVector.h
Go to the documentation of this file.
1 /*******************************************************************************************************
2 ReadFramework is the basis for modules developed at CVL/TU Wien for the EU project READ.
3 
4 Copyright (C) 2016 Markus Diem <diem@caa.tuwien.ac.at>
5 Copyright (C) 2016 Stefan Fiel <fiel@caa.tuwien.ac.at>
6 Copyright (C) 2016 Florian Kleber <kleber@caa.tuwien.ac.at>
7 
8 This file is part of ReadFramework.
9 
10 ReadFramework is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14 
15 ReadFramework is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 The READ project has received funding from the European Union’s Horizon 2020
24 research and innovation programme under grant agreement No 674943
25 
26 related links:
27 [1] http://www.caa.tuwien.ac.at/cvl/
28 [2] https://transkribus.eu/Transkribus/
29 [3] https://github.com/TUWien/
30 [4] http://nomacs.org
31 *******************************************************************************************************/
32 
33 #pragma once
34 
35 #include "BaseModule.h"
36 #include "Shapes.h"
37 
38 #pragma warning(push, 0) // no warnings from includes
39 // Qt Includes
40 #include <QVector>
41 #pragma warning(pop)
42 
43 #pragma warning (disable: 4251) // inlined Qt functions in dll interface
44 
45 #ifndef DllCoreExport
46 #ifdef DLL_CORE_EXPORT
47 #define DllCoreExport Q_DECL_EXPORT
48 #else
49 #define DllCoreExport Q_DECL_IMPORT
50 #endif
51 #endif
52 
53 // Qt defines
54 
55 namespace rdf {
56 
57 
59 
60  public:
62 
63  double sigma() const;
64  void setSigma(double s);
65 
66  bool normGrad() const;
67  void setNormGrad(bool n);
68 
69  bool perpendAngle() const;
70  void setPerpendAngle(bool p);
71 
72  QString toString() const override;
73 
74  private:
75  void load(const QSettings& settings) override;
76  void save(QSettings& settings) const override;
77 
78  double mSigma = 1.75; //filter parameter: maximal difference of line orientation compared to the result of the Rotation module (default: 5 deg)
79  bool mNormGrad = true;
80  bool mPerpendAngle = false; //if you want to get perpendicular angles compared to the gradient orientation
81 };
82 
84 
85 
86 public:
87  GradientVector(const cv::Mat& img, const cv::Mat& mask = cv::Mat());
88 
89  cv::Mat debugGaussImg();
90  cv::Mat magImg();
91  cv::Mat radImg();
92  cv::Mat mask();
93 
94  void setAnchor(cv::Point a);
95  cv::Point anchor() const;
96 
97  void setDxKernel(const cv::Mat& m);
98  void setDyKernel(const cv::Mat& m);
99 
100  double minVal() const;
101  double maxVal() const;
102 
103 
104  bool isEmpty() const override;
105  virtual bool compute() override;
106 
107  QSharedPointer<GradientVectorConfig> config() const;
108 
109  virtual QString toString() const override;
110 
111 protected:
112  bool checkInput() const override;
113  void computeGradients();
114  void computeGradMag(bool norm);
115  void computeGradAngle();
116 
117 
118 private:
119 
120  double mMinVal;
121  double mMaxVal;
122 
123  cv::Mat mSrcImg; // input image
124  cv::Mat mMask; // input mask
125  cv::Mat mGaussImg; // gaussian image
126  cv::Mat mDxImg; // x derivative image
127  cv::Mat mDyImg; // y derivative image
128  cv::Mat mMagImg; // gradient magnitude image
129  cv::Mat mRadImg; // orientation image (in radians)
130 
131  cv::Point mAnchor = cv::Point(-1, -1);
132  cv::Mat mDxKernel;
133  cv::Mat mDyKernel;
134 
135 };
136 
137 }
Definition: BaseModule.h:63
Definition: GradientVector.h:83
#define DllCoreExport
Definition: BaseImageElement.h:43
config
Definition: DependencyCollector.py:271
DllCoreExport bool save(const QImage &img, const QString &savePath, int compression=-1)
Saves the specified QImage img.
Definition: Image.cpp:180
Definition: GradientVector.h:58
DllCoreExport QImage load(const QString &path, bool *ok=0)
Definition: Image.cpp:152
This is the base class for all modules. It provides all functions which are implemented by the module...
Definition: BaseModule.h:126
Definition: Algorithms.cpp:45