diff --git a/openbr/plugins/cvt.cpp b/openbr/plugins/cvt.cpp index fc8d9fb..2dedfcd 100644 --- a/openbr/plugins/cvt.cpp +++ b/openbr/plugins/cvt.cpp @@ -162,6 +162,34 @@ BR_REGISTER(Transform, EnsureChannelsTransform) /*! * \ingroup transforms + * \brief Drop the alpha channel (if exists). + * \author Austin Blanton \cite imaus10 + */ +class DiscardAlphaTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + if (src.m().channels() > 4 || src.m().channels() == 2) { + dst.file.fte = true; + return; + } + + dst = src; + if (src.m().channels() == 4) { + std::vector mv; + split(src, mv); + mv.pop_back(); + merge(mv, dst); + } + } +}; + +BR_REGISTER(Transform, DiscardAlphaTransform) + +/*! + * \ingroup transforms * \brief Normalized RG color space. * \author Josh Klontz \cite jklontz */