Each reflect each boundary value outwards This mimics what the skimage.filters.gaussian_filter(... mode="nearest") does.
(x, axis, depth)
| 246 | |
| 247 | |
| 248 | def nearest(x, axis, depth): |
| 249 | """Each reflect each boundary value outwards |
| 250 | |
| 251 | This mimics what the skimage.filters.gaussian_filter(... mode="nearest") |
| 252 | does. |
| 253 | """ |
| 254 | left = ( |
| 255 | (slice(None, None, None),) * axis |
| 256 | + (slice(0, 1),) |
| 257 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 258 | ) |
| 259 | right = ( |
| 260 | (slice(None, None, None),) * axis |
| 261 | + (slice(-1, -2, -1),) |
| 262 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 263 | ) |
| 264 | |
| 265 | l = repeat(x[left], depth, axis=axis) |
| 266 | r = repeat(x[right], depth, axis=axis) |
| 267 | |
| 268 | l, r = _remove_overlap_boundaries(l, r, axis, depth) |
| 269 | |
| 270 | return concatenate([l, x, r], axis=axis) |
| 271 | |
| 272 | |
| 273 | def constant(x, axis, depth, value): |
searching dependent graphs…