Commit a0ffa4ad3e869b9d03e4e4e72454f8208fc7ea9f

Authored by jklontz
2 parents 44cdf3bb a12c0111

Merge pull request #19 from biometrics/transforms

Added DownsampleTransform
sdk/plugins/reduce.cpp
@@ -122,6 +122,7 @@ BR_REGISTER(Transform, StatTransform) @@ -122,6 +122,7 @@ BR_REGISTER(Transform, StatTransform)
122 /*! 122 /*!
123 * \ingroup transforms 123 * \ingroup transforms
124 * \brief Downsample the rows and columns of a matrix. 124 * \brief Downsample the rows and columns of a matrix.
  125 + * \author Lacey Best-Rowden \cite lbestrowden
125 */ 126 */
126 class DownsampleTransform : public UntrainableTransform 127 class DownsampleTransform : public UntrainableTransform
127 { 128 {
@@ -131,9 +132,15 @@ class DownsampleTransform : public UntrainableTransform @@ -131,9 +132,15 @@ class DownsampleTransform : public UntrainableTransform
131 132
132 void project(const Template &src, Template &dst) const 133 void project(const Template &src, Template &dst) const
133 { 134 {
  135 + if (src.m().channels() != 1)
  136 + qFatal("Expected 1 channel matrix.");
134 Mat input = src.m(); 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 dst.m() = output; 144 dst.m() = output;
138 } 145 }
139 }; 146 };
share/openbr/openbr.bib
@@ -28,6 +28,11 @@ @@ -28,6 +28,11 @@
28 Author = {Charles A. Otto}, 28 Author = {Charles A. Otto},
29 Howpublished = {https://github.com/caotto}, 29 Howpublished = {https://github.com/caotto},
30 Title = {ottochar at gmail.com}} 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 % Software 38 % Software