| 110 | typename image_array_type |
| 111 | > |
| 112 | void scan_image_old ( |
| 113 | std::vector<std::pair<double, point> >& dets, |
| 114 | const image_array_type& images, |
| 115 | const std::vector<std::pair<unsigned int, rectangle> >& rects, |
| 116 | const double thresh, |
| 117 | const unsigned long max_dets |
| 118 | ) |
| 119 | { |
| 120 | dets.clear(); |
| 121 | if (max_dets == 0) |
| 122 | return; |
| 123 | |
| 124 | typedef typename image_array_type::type::type pixel_type; |
| 125 | typedef typename promote<pixel_type>::type ptype; |
| 126 | |
| 127 | std::vector<std::vector<ptype> > column_sums(rects.size()); |
| 128 | for (unsigned long i = 0; i < column_sums.size(); ++i) |
| 129 | { |
| 130 | const typename image_array_type::type& img = images[rects[i].first]; |
| 131 | column_sums[i].resize(img.nc() + rects[i].second.width(),0); |
| 132 | |
| 133 | const long top = -1 + rects[i].second.top(); |
| 134 | const long bottom = -1 + rects[i].second.bottom(); |
| 135 | long left = rects[i].second.left()-1; |
| 136 | |
| 137 | // initialize column_sums[i] at row -1 |
| 138 | for (unsigned long j = 0; j < column_sums[i].size(); ++j) |
| 139 | { |
| 140 | rectangle strip(left,top,left,bottom); |
| 141 | strip = strip.intersect(get_rect(img)); |
| 142 | if (!strip.is_empty()) |
| 143 | { |
| 144 | column_sums[i][j] = sum(matrix_cast<ptype>(subm(mat(img),strip))); |
| 145 | } |
| 146 | |
| 147 | ++left; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | |
| 152 | const rectangle area = get_rect(images[0]); |
| 153 | |
| 154 | for (long r = 0; r < images[0].nr(); ++r) |
| 155 | { |
| 156 | // set to sum at point(-1,r). i.e. should be equal to sum_of_rects_in_images(images, rects, point(-1,r)) |
| 157 | // We compute it's value in the next loop. |
| 158 | ptype cur_sum = 0; |
| 159 | |
| 160 | // Update the first part of column_sums since we only work on the c+width part of column_sums |
| 161 | // in the main loop. |
| 162 | for (unsigned long i = 0; i < rects.size(); ++i) |
| 163 | { |
| 164 | const typename image_array_type::type& img = images[rects[i].first]; |
| 165 | const long top = r + rects[i].second.top() - 1; |
| 166 | const long bottom = r + rects[i].second.bottom(); |
| 167 | const long width = rects[i].second.width(); |
| 168 | for (long k = 0; k < width; ++k) |
| 169 | { |