From 069d64edffb5486083f27c137e8ef3c21f506683 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Thu, 19 Feb 2015 16:19:47 -0500 Subject: [PATCH] Added threshold --- openbr/plugins/imgproc/threshold.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+), 0 deletions(-) create mode 100644 openbr/plugins/imgproc/threshold.cpp diff --git a/openbr/plugins/imgproc/threshold.cpp b/openbr/plugins/imgproc/threshold.cpp new file mode 100644 index 0000000..a31fafd --- /dev/null +++ b/openbr/plugins/imgproc/threshold.cpp @@ -0,0 +1,44 @@ +#include + +#include + +using namespace cv; + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Wraps OpenCV's adaptive thresholding. + * \author Scott Klum \cite sklum + */ +class ThresholdTransform : public UntrainableTransform +{ + Q_OBJECT + + Q_ENUMS(Method) + Q_ENUMS(Type) + Q_PROPERTY(int thresh READ get_thresh WRITE set_thresh RESET reset_thresh STORED false) + Q_PROPERTY(int maxValue READ get_maxValue WRITE set_maxValue RESET reset_maxValue STORED false) + + public: + BR_PROPERTY(int, thresh, 0) + BR_PROPERTY(int, maxValue, 255) + + + void project(const Template &src, Template &dst) const + { + dst = src; + + Mat mask; + threshold(src, mask, thresh, maxValue, THRESH_BINARY+THRESH_OTSU); + + dst.file.set("Mask",QVariant::fromValue(mask)); + } +}; + +BR_REGISTER(Transform, ThresholdTransform) + +} // namespace br + +#include "imgproc/threshold.moc" -- libgit2 0.21.4