Postprocess: average around UV in range?

Is there a way to get an average of colors (or other data) for an area of a render-result around a certain UV coordinate?

This stuff is so important for outliners or smooth edge gradients in general.

There are no loops or anything, so the only way I’ve come up with is to “manually” check every texel(?) within a range around the coordinate. But there must be a way to do this properly, right?..

Or maybe I should write into a sampler from the UV and then have a second pass to use this data?? Not that I know how that would work, or if it’s really the best way… would appreciate some advice here.