Commit 5218806631801fc69f79cbedb8269241888ce0f0
1 parent
bbc08be4
Add a 'byRow' option to Normalize, to operate on rows of a matrix independently
Showing
1 changed file
with
13 additions
and
1 deletions
openbr/plugins/normalize.cpp
| ... | ... | @@ -58,6 +58,9 @@ class NormalizeTransform : public UntrainableTransform |
| 58 | 58 | Q_ENUMS(NormType) |
| 59 | 59 | Q_PROPERTY(NormType normType READ get_normType WRITE set_normType RESET reset_normType STORED false) |
| 60 | 60 | |
| 61 | + Q_PROPERTY(bool ByRow READ get_ByRow WRITE set_ByRow RESET reset_ByRow STORED false) | |
| 62 | + BR_PROPERTY(bool, ByRow, false) | |
| 63 | + | |
| 61 | 64 | public: |
| 62 | 65 | /*!< */ |
| 63 | 66 | enum NormType { Inf = NORM_INF, |
| ... | ... | @@ -69,7 +72,16 @@ private: |
| 69 | 72 | |
| 70 | 73 | void project(const Template &src, Template &dst) const |
| 71 | 74 | { |
| 72 | - normalize(src, dst, 1, 0, normType, CV_32F); | |
| 75 | + if (!ByRow) normalize(src, dst, 1, 0, normType, CV_32F); | |
| 76 | + else { | |
| 77 | + dst = src; | |
| 78 | + for (int i=0; i<dst.m().rows; i++) { | |
| 79 | + Mat temp; | |
| 80 | + cv::normalize(dst.m().row(i), temp, 1, 0, normType); | |
| 81 | + temp.copyTo(dst.m().row(i)); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 73 | 85 | } |
| 74 | 86 | }; |
| 75 | 87 | ... | ... |