I implemented a sparsifying max filter that takes a sliding window of length $M$ that runs over a time series of length $L$, keeps the maximum value in that window, and put zeros everywhere else at the output. The windowed outputs are lagged and summed to simulate a convolution operation. For example, if the input is
$M=4$, and we use a zero-padding of length $3$ at both ends of the input, we will get the output
$$[0, 0, 0, 4, 5, 28, 6, 2, 0, 10, 0, 0, 0, 4, 5, 6, 7, 32, 0, 0, 0].$$
At first, I thought that this was a dilation operation, but then I realized that what I did is different since the dilation doesn't sparsify. Is there another math operation, or algorithm, that do something similar to what I did? or maybe closer than the dilation or moving max?