MCPcopy Create free account
hub / github.com/PDAL/PDAL / dilateDiamond

Function dilateDiamond

pdal/private/MathUtils.cpp:259–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void dilateDiamond(std::vector<double>& data, size_t rows, size_t cols, int iterations)
260{
261 std::vector<double> out(data.size(), std::numeric_limits<double>::lowest());
262 std::array<size_t, 5> idx;
263
264 for (int iter = 0; iter < iterations; ++iter)
265 {
266 for (size_t col = 0; col < cols; ++col)
267 {
268 size_t index = col*rows;
269 for (size_t row = 0; row < rows; ++row)
270 {
271 // Find the index into the vector of the current cell. Then
272 // find the index of the cells to the right/left/above/below
273 // if they exist.
274 size_t j = 0;
275 idx[j++] = index+row;
276 if (row > 0)
277 idx[j++] = idx[0]-1;
278 if (row < rows-1)
279 idx[j++] = idx[0]+1;
280 if (col > 0)
281 idx[j++] = idx[0]-rows;
282 if (col < cols-1)
283 idx[j++] = idx[0]+rows;
284 // If the data at the test cell pos is greater than that
285 // from the last iteration, set the value to the maximum of
286 // the value of those cells.
287 for (size_t i = 0; i < j; ++i)
288 {
289 if (data[idx[i]] > out[index+row])
290 out[index+row] = data[idx[i]];
291 }
292 }
293 }
294 data.swap(out);
295 }
296}
297
298void erodeDiamond(std::vector<double>& data, size_t rows, size_t cols,
299 int iterations)

Callers 4

TESTFunction · 0.85
createZInetMethod · 0.85
progressiveFilterMethod · 0.85
processGroundMethod · 0.85

Calls 2

swapMethod · 0.80
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68