In more detail: I have a big image and need to downsize it. Say my image is of size 1000x1000 and I want to bring it down to 100x100. What I want to do is tile it with 10x10 blocks and replace each block by its median or mean, maximum… This operation is called pooling I think.
More generally I would like to be able to replace each 10x10 block by say a 4x4 block with respect to some function “f : 10x10 → 4x4”
Is there a package that implements these kinds of operations?
That has bad performance (also not exactly equivalent, but that does probably not matter in practice). For example applying naively the 10x10 median filter and then subsampling does 100 times more work then necessary.
Hello,
probably this known, but when you apply restrict, what happens if my input matrix has NaN values, I did tried for my case, and I see that more empty regions appear, I suppose that the ouput within each cell is NaN if there is at least one during the computation. It would be feasible to say that if there is NaNs but at least one real value or more, then operate on those and give out a real value and not a NaN?
It probably wouldn’t be hard to modify restrict to do that, though it would very likely have a performance impact so it would be best to keep the current implementation intact. One possibility would be to pass a function as an argument that would tally the local neighborhood. E.g., the current algorithm might accept