diff --git a/sdk/plugins/hist.cpp b/sdk/plugins/hist.cpp index 39d0b44..0a87290 100644 --- a/sdk/plugins/hist.cpp +++ b/sdk/plugins/hist.cpp @@ -66,6 +66,38 @@ BR_REGISTER(Transform, HistTransform) /*! * \ingroup transforms + * \brief Quantizes the values into bins. + * \author Josh Klontz \cite jklontz + */ +class BinTransform : public UntrainableTransform +{ + Q_OBJECT + Q_PROPERTY(float min READ get_min WRITE set_min RESET reset_min STORED false) + Q_PROPERTY(float max READ get_max WRITE set_max RESET reset_max STORED false) + Q_PROPERTY(int bins READ get_bins WRITE set_bins RESET reset_bins STORED false) + Q_PROPERTY(bool split READ get_split WRITE set_split RESET reset_split STORED false) + BR_PROPERTY(float, min, 0) + BR_PROPERTY(float, max, 255) + BR_PROPERTY(int, bins, 8) + BR_PROPERTY(bool, split, false) + + void project(const Template &src, Template &dst) const + { + src.m().convertTo(dst, bins > 256 ? CV_16U : CV_8U, bins/(max-min)); + if (!split) return; + + Mat input = dst; + QList outputs; outputs.reserve(bins); + for (int i=0; i +#include + +namespace br +{ + +/*! + * \ingroup transforms + * \brief Computes integral image. + * \author Josh Klontz \cite jklontz + */ +class IntegralTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + cv::integral(src, dst); + } +}; + +BR_REGISTER(Transform, IntegralTransform) + +/*! + * \ingroup transforms + * \brief Computes magnitude and/or angle of image. + * \author Josh Klontz \cite jklontz + */ +class GradientTransform : public UntrainableTransform +{ + Q_OBJECT + Q_ENUMS(Channel) + Q_PROPERTY(Channel channel READ get_channel WRITE set_channel RESET reset_channel STORED false) + +public: + enum Channel { Magnitude, Angle, MagnitudeAndAngle }; + +private: + BR_PROPERTY(Channel, channel, Angle) + + void project(const Template &src, Template &dst) const + { + if (src.m().type() != CV_8UC1) qFatal("Requires CV_8UC1 input."); + cv::Mat dx, dy, magnitude, angle; + cv::Sobel(src, dx, CV_32F, 1, 0); + cv::Sobel(src, dy, CV_32F, 0, 1); + cv::cartToPolar(dx, dy, magnitude, angle, true); + if ((channel == Magnitude) || (channel == MagnitudeAndAngle)) + dst.append(magnitude); + if ((channel == Angle) || (channel == MagnitudeAndAngle)) + dst.append(angle); + } +}; + +BR_REGISTER(Transform, GradientTransform) + +} // namespace br + +#include "integral.moc"