AFAIK raster data can be read in three ways:
- by cell (inefficient);
- by image (quite efficient);
- by blocks (the most efficient way).
Without reinventing the wheel, I suggest to read these enlightening slides of Chris Garrard.
So the most efficient method is read data by block, however this would cause a data loss in correspondence of pixels located over the block boundaries while applying the filter. So a safe alternative way consists into reading the entire image at once.
On the computational side, I should use gdalfilter.py and implicitly the VRT KernelFilteredSource approach in order to apply the needed filters and, above all, avoid heavy calculations.