| 53 | } |
| 54 | |
| 55 | const Matrix SlidingWindowIterator::getData() const |
| 56 | { |
| 57 | const Index centerIndex(*(*this)); |
| 58 | const Index windowMargin(Index::Constant(windowMargin_)); |
| 59 | const Index originalTopLeftIndex(centerIndex - windowMargin); |
| 60 | Index topLeftIndex(originalTopLeftIndex); |
| 61 | boundIndexToRange(topLeftIndex, size_); |
| 62 | Index bottomRightIndex(centerIndex + windowMargin); |
| 63 | boundIndexToRange(bottomRightIndex, size_); |
| 64 | const Size adjustedWindowSize(bottomRightIndex - topLeftIndex + Size::Ones()); |
| 65 | |
| 66 | switch (edgeHandling_) { |
| 67 | case EdgeHandling::INSIDE: |
| 68 | case EdgeHandling::CROP: |
| 69 | return data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1)); |
| 70 | case EdgeHandling::EMPTY: |
| 71 | case EdgeHandling::MEAN: |
| 72 | const Matrix data = data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1)); |
| 73 | Matrix returnData(windowSize_, windowSize_); |
| 74 | if (edgeHandling_ == EdgeHandling::EMPTY) returnData.setConstant(NAN); |
| 75 | else if (edgeHandling_ == EdgeHandling::MEAN) returnData.setConstant(data.meanOfFinites()); |
| 76 | const Index topLeftIndexShift(topLeftIndex - originalTopLeftIndex); |
| 77 | returnData.block(topLeftIndexShift(0), topLeftIndexShift(1), adjustedWindowSize(0), adjustedWindowSize(1)) = |
| 78 | data_.block(topLeftIndex(0), topLeftIndex(1), adjustedWindowSize(0), adjustedWindowSize(1)); |
| 79 | return returnData; |
| 80 | } |
| 81 | return Matrix::Zero(0, 0); |
| 82 | } |
| 83 | |
| 84 | void SlidingWindowIterator::setup(const GridMap& gridMap) |
| 85 | { |