Commit a0ffa4ad3e869b9d03e4e4e72454f8208fc7ea9f
Merge pull request #19 from biometrics/transforms
Added DownsampleTransform
Showing
2 changed files
with
14 additions
and
2 deletions
sdk/plugins/reduce.cpp
| ... | ... | @@ -122,6 +122,7 @@ BR_REGISTER(Transform, StatTransform) |
| 122 | 122 | /*! |
| 123 | 123 | * \ingroup transforms |
| 124 | 124 | * \brief Downsample the rows and columns of a matrix. |
| 125 | + * \author Lacey Best-Rowden \cite lbestrowden | |
| 125 | 126 | */ |
| 126 | 127 | class DownsampleTransform : public UntrainableTransform |
| 127 | 128 | { |
| ... | ... | @@ -131,9 +132,15 @@ class DownsampleTransform : public UntrainableTransform |
| 131 | 132 | |
| 132 | 133 | void project(const Template &src, Template &dst) const |
| 133 | 134 | { |
| 135 | + if (src.m().channels() != 1) | |
| 136 | + qFatal("Expected 1 channel matrix."); | |
| 134 | 137 | Mat input = src.m(); |
| 135 | - Mat output; | |
| 136 | - (void) input; // TODO: write me! | |
| 138 | + Mat output(ceil((double)input.rows/k), ceil((double)input.cols/k), CV_32FC1); | |
| 139 | + for (int r=0; r<output.rows; r++) { | |
| 140 | + for (int c=0; c<output.cols; c++) { | |
| 141 | + output.at<float>(r,c) = input.at<float>(r*k,c*k); | |
| 142 | + } | |
| 143 | + } | |
| 137 | 144 | dst.m() = output; |
| 138 | 145 | } |
| 139 | 146 | }; | ... | ... |
share/openbr/openbr.bib
| ... | ... | @@ -28,6 +28,11 @@ |
| 28 | 28 | Author = {Charles A. Otto}, |
| 29 | 29 | Howpublished = {https://github.com/caotto}, |
| 30 | 30 | Title = {ottochar at gmail.com}} |
| 31 | + | |
| 32 | +@misc{lbestrowden, | |
| 33 | + Author = {Lacey S. Best-Rowden}, | |
| 34 | + Howpublished = {https://github.com/lbestrowden}, | |
| 35 | + Title = {bestrow1 at msu.edu}} | |
| 31 | 36 | |
| 32 | 37 | |
| 33 | 38 | % Software | ... | ... |