Commit 8afb837cf7dcd0e8f96fef0efd8641b443c7fef0

Authored by lbestrowden
1 parent 5c7fd6bf

Added DownsampleTransform

Downsample the rows and columns of a matrix.
Showing 1 changed file with 7 additions and 2 deletions
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 {
@@ -132,8 +133,12 @@ class DownsampleTransform : public UntrainableTransform @@ -132,8 +133,12 @@ class DownsampleTransform : public UntrainableTransform
132 void project(const Template &src, Template &dst) const 133 void project(const Template &src, Template &dst) const
133 { 134 {
134 Mat input = src.m(); 135 Mat input = src.m();
135 - Mat output;  
136 - (void) input; // TODO: write me! 136 + Mat output(ceil((double)input.rows/k), ceil((double)input.cols/k), CV_32FC1);
  137 + for (int r=0; r<output.rows; r++) {
  138 + for (int c=0; c<output.cols; c++) {
  139 + output.at<float>(r,c) = input.at<float>(r*k,c*k);
  140 + }
  141 + }
137 dst.m() = output; 142 dst.m() = output;
138 } 143 }
139 }; 144 };