From 025f9965b56261bc0105bb1b575095b109daaf9f Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Thu, 19 Feb 2015 17:10:30 -0500 Subject: [PATCH] Better thresholding --- openbr/plugins/imgproc/threshold.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openbr/plugins/imgproc/threshold.cpp b/openbr/plugins/imgproc/threshold.cpp index a31fafd..1e4f53f 100644 --- a/openbr/plugins/imgproc/threshold.cpp +++ b/openbr/plugins/imgproc/threshold.cpp @@ -16,22 +16,31 @@ class ThresholdTransform : public UntrainableTransform { Q_OBJECT - Q_ENUMS(Method) Q_ENUMS(Type) + Q_PROPERTY(Type type READ get_type WRITE set_type RESET reset_type STORED false) + Q_PROPERTY(bool otsu READ get_otsu WRITE set_otsu RESET reset_otsu STORED false) 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: +public: + enum Type { Binary = THRESH_BINARY, + BinaryInv = THRESH_BINARY_INV, + Trunc = THRESH_TRUNC, + ToZero = THRESH_TOZERO, + ToZeroInv = THRESH_TOZERO_INV}; + +private: + BR_PROPERTY(Type, type, Binary) + BR_PROPERTY(bool, otsu, false) 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); + threshold(src, mask, thresh, maxValue, otsu ? type+THRESH_OTSU : type); dst.file.set("Mask",QVariant::fromValue(mask)); } -- libgit2 0.21.4