Commit ae7904e7a87c0d5ef17b4bfeddbf3221d6a7325f
1 parent
c9ff1cc0
Add DiscardAlphaTransform to drop 4th channel if exists
Showing
1 changed file
with
28 additions
and
0 deletions
openbr/plugins/cvt.cpp
| ... | ... | @@ -162,6 +162,34 @@ BR_REGISTER(Transform, EnsureChannelsTransform) |
| 162 | 162 | |
| 163 | 163 | /*! |
| 164 | 164 | * \ingroup transforms |
| 165 | + * \brief Drop the alpha channel (if exists). | |
| 166 | + * \author Austin Blanton \cite imaus10 | |
| 167 | + */ | |
| 168 | +class DiscardAlphaTransform : public UntrainableTransform | |
| 169 | +{ | |
| 170 | + Q_OBJECT | |
| 171 | + | |
| 172 | + void project(const Template &src, Template &dst) const | |
| 173 | + { | |
| 174 | + if (src.m().channels() > 4 || src.m().channels() == 2) { | |
| 175 | + dst.file.fte = true; | |
| 176 | + return; | |
| 177 | + } | |
| 178 | + | |
| 179 | + dst = src; | |
| 180 | + if (src.m().channels() == 4) { | |
| 181 | + std::vector<Mat> mv; | |
| 182 | + split(src, mv); | |
| 183 | + mv.pop_back(); | |
| 184 | + merge(mv, dst); | |
| 185 | + } | |
| 186 | + } | |
| 187 | +}; | |
| 188 | + | |
| 189 | +BR_REGISTER(Transform, DiscardAlphaTransform) | |
| 190 | + | |
| 191 | +/*! | |
| 192 | + * \ingroup transforms | |
| 165 | 193 | * \brief Normalized RG color space. |
| 166 | 194 | * \author Josh Klontz \cite jklontz |
| 167 | 195 | */ | ... | ... |