-
Notifications
You must be signed in to change notification settings - Fork 343
Closed
Description
Is there an equivalent for np.pad
I'm trying to make a filter for arrays using windows, however the output array is smaller than the input array, which is something I want to avoid. I think this can be solved by padding the input array to be a bit larger before using it.
My code:
let input = Array2::<f32>::zeros((300, 200));
let kernel = array![[0.0625, 0.125, 0.0625], [0.125, 0.25, 0.125], [0.0625, 0.125, 0.0625]];
let output = ndarray::Zip::from(input.windows(kernel.raw_dim()))
.apply_collect(|window| {
(&window * &kernel).sum()
});
assert_eq!(input.shape(), output.shape()); // this fails
I'm new to both rust and ndarray, so there might be an obvious solution I'm missing.
imjasonmiller, fzyzcjy, MarcelRobitaille, tgsmith61591 and nbro
Metadata
Metadata
Assignees
Labels
No labels