Commit 069d64edffb5486083f27c137e8ef3c21f506683
1 parent
ade55607
Added threshold
Showing
1 changed file
with
44 additions
and
0 deletions
openbr/plugins/imgproc/threshold.cpp
0 → 100644
| 1 | +#include <opencv2/imgproc/imgproc.hpp> | |
| 2 | + | |
| 3 | +#include <openbr/plugins/openbr_internal.h> | |
| 4 | + | |
| 5 | +using namespace cv; | |
| 6 | + | |
| 7 | +namespace br | |
| 8 | +{ | |
| 9 | + | |
| 10 | +/*! | |
| 11 | + * \ingroup transforms | |
| 12 | + * \brief Wraps OpenCV's adaptive thresholding. | |
| 13 | + * \author Scott Klum \cite sklum | |
| 14 | + */ | |
| 15 | +class ThresholdTransform : public UntrainableTransform | |
| 16 | +{ | |
| 17 | + Q_OBJECT | |
| 18 | + | |
| 19 | + Q_ENUMS(Method) | |
| 20 | + Q_ENUMS(Type) | |
| 21 | + Q_PROPERTY(int thresh READ get_thresh WRITE set_thresh RESET reset_thresh STORED false) | |
| 22 | + Q_PROPERTY(int maxValue READ get_maxValue WRITE set_maxValue RESET reset_maxValue STORED false) | |
| 23 | + | |
| 24 | + public: | |
| 25 | + BR_PROPERTY(int, thresh, 0) | |
| 26 | + BR_PROPERTY(int, maxValue, 255) | |
| 27 | + | |
| 28 | + | |
| 29 | + void project(const Template &src, Template &dst) const | |
| 30 | + { | |
| 31 | + dst = src; | |
| 32 | + | |
| 33 | + Mat mask; | |
| 34 | + threshold(src, mask, thresh, maxValue, THRESH_BINARY+THRESH_OTSU); | |
| 35 | + | |
| 36 | + dst.file.set("Mask",QVariant::fromValue(mask)); | |
| 37 | + } | |
| 38 | +}; | |
| 39 | + | |
| 40 | +BR_REGISTER(Transform, ThresholdTransform) | |
| 41 | + | |
| 42 | +} // namespace br | |
| 43 | + | |
| 44 | +#include "imgproc/threshold.moc" | ... | ... |