| 296 | } |
| 297 | |
| 298 | void erodeDiamond(std::vector<double>& data, size_t rows, size_t cols, |
| 299 | int iterations) |
| 300 | { |
| 301 | std::vector<double> out(data.size(), (std::numeric_limits<double>::max)()); |
| 302 | std::array<size_t, 5> idx; |
| 303 | |
| 304 | for (int iter = 0; iter < iterations; ++iter) |
| 305 | { |
| 306 | for (size_t col = 0; col < cols; ++col) |
| 307 | { |
| 308 | size_t index = col*rows; |
| 309 | for (size_t row = 0; row < rows; ++row) |
| 310 | { |
| 311 | size_t j = 0; |
| 312 | idx[j++] = index+row; |
| 313 | if (row > 0) |
| 314 | idx[j++] = idx[0]-1; |
| 315 | if (row < rows-1) |
| 316 | idx[j++] = idx[0]+1; |
| 317 | if (col > 0) |
| 318 | idx[j++] = idx[0]-rows; |
| 319 | if (col < cols-1) |
| 320 | idx[j++] = idx[0]+rows; |
| 321 | for (size_t i = 0; i < j; ++i) |
| 322 | { |
| 323 | if (data[idx[i]] < out[index+row]) |
| 324 | out[index+row] = data[idx[i]]; |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | data.swap(out); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | Eigen::MatrixXd pointViewToEigen(const PointView& view) |
| 333 | { |