41 #pragma warning(push, 0) // no warnings from includes 42 #include <opencv2/core.hpp> 46 #ifdef DLL_CORE_EXPORT 47 #define DllCoreExport Q_DECL_EXPORT 49 #define DllCoreExport Q_DECL_IMPORT 64 virtual QString toString()
const override;
66 int numLayers()
const;
73 void load(
const QSettings& settings)
override;
74 void save(QSettings& settings)
const override;
83 template <
class SuperPixelModule>
85 static_assert(std::is_base_of<SuperPixelBase, SuperPixelModule>::value,
"T must derive from SuperPixelBase");
89 mConfig = QSharedPointer<ScaleSpaceSPConfig>::create();
99 cv::Mat img = mSrcImg.clone();
101 cv::normalize(img, img, 255, 0, cv::NORM_MINMAX);
107 for (
int idx = 0; idx <
config()->numLayers(); idx++) {
110 if (
config()->minLayer() <= idx) {
112 SuperPixelModule spm(img);
113 spm.setPyramidLevel(idx);
114 qDebug() <<
"computing new layer...";
118 mWarning <<
"could not compute super pixels for layer #" << idx;
123 for (
auto p :
set.pixels()) {
124 p->setPyramidLevel(idx);
126 p->
setId(QString::number(idCnt));
133 double sf = std::pow(2, idx);
140 cv::resize(img, img, cv::Size(), 0.5, 0.5, CV_INTER_AREA);
144 mSet.filterDuplicates();
145 mInfo << mSet.size() <<
"pixels extracted in" << dt;
150 cv::Mat
draw(
const cv::Mat & img,
const QColor& col = QColor())
const {
156 QVector<PixelSet> s = mSet.splitScales();
157 for (
int idx = s.size() - 1; idx >= 0; idx--) {
170 return config()->toString();
173 QSharedPointer<ScaleSpaceSPConfig>
config()
const {
174 return qSharedPointerDynamicCast<ScaleSpaceSPConfig>(mConfig);
ScaleSpaceSuperPixel(const cv::Mat &img)
Definition: SuperPixelScaleSpace.h:88
Definition: BaseModule.h:63
static Config & instance()
Definition: Settings.cpp:101
#define DllCoreExport
Definition: BaseImageElement.h:43
bool compute() override
Runs the algorithm implemented by the module.
Definition: SuperPixelScaleSpace.h:92
DllCoreExport QColor randColor(double alpha=1.0)
Returns a pleasent color.
Definition: Drawer.cpp:79
PixelSet stores and manipulates pixel collections.
Definition: PixelSet.h:172
Flags turns enums into typesave flags It is strongly related (copied) from Useage: enum mDrawFlags { ...
Definition: Utils.h:166
DllCoreExport QImage mat2QImage(const cv::Mat &img, bool toRGB=false)
Converts a cv::Mat to QImage.
Definition: Image.cpp:106
#define mInfo
Definition: BaseModule.h:59
QString toString() const override
Converts the module's parameters and results to a string.
Definition: SuperPixelScaleSpace.h:169
Definition: SuperPixelScaleSpace.h:59
static cv::Mat grayscale(const cv::Mat &src)
Returns the Luminance channel of Luv which is better than the RGB2Gray.
Definition: ImageProcessor.cpp:69
Creates a scale space and runs the SuperPixelModule on each scale. Use this class to extract SuperPix...
Definition: SuperPixelScaleSpace.h:84
static GlobalConfig & global()
Definition: Settings.cpp:109
cv::Mat draw(const cv::Mat &img, const QColor &col=QColor()) const
Definition: SuperPixelScaleSpace.h:150
config
Definition: DependencyCollector.py:271
void setId(const QString &id)
Sets the (preferably unique) ID. If no ID is set, a unqiue ID is generated and assigned.
Definition: BaseImageElement.cpp:99
Base class implementation for SuperPixel generating modules.
Definition: SuperPixel.h:68
#define mWarning
Definition: BaseModule.h:60
DllCoreExport bool save(const QImage &img, const QString &savePath, int compression=-1)
Saves the specified QImage img.
Definition: Image.cpp:180
QSharedPointer< ScaleSpaceSPConfig > config() const
Definition: SuperPixelScaleSpace.h:173
DllCoreExport QImage load(const QString &path, bool *ok=0)
Definition: Image.cpp:152
Definition: Algorithms.cpp:45
Definition: PixelSet.h:187
void setNumScales(int ns)
Definition: Settings.cpp:74
DllCoreExport cv::Mat qImage2Mat(const QImage &img)
Converts a QImage to a cv::Mat.
Definition: Image.cpp:60