I'm classifying vegetation types in QGIS (3.10). I have a pretty coarse raster that I want to smooth out. The standard approach seems to be to polygonize and then apply various smoothing algorithms (e.g. Chaiken or sliding_averaging in Grass'
v.generalize). This works fine for rectangular raster polygons, but doesn't smooth out thin diagonal features well. For instance, if the raster is
then the output has 3 islands of A's and 4 of C's. Technically, they may be one polygon pinched where the A's (resp C's) meet at the diagonal, but they appear as islands, not truly connected. Smoothing keeps sharp angles at the diagonal touchpoints rather than "building a bridge".
I'm thinking of a solution which involves building these diagonal bridges in a densified raster (for computational efficiency) prior to polygonizing. The output would be something like
It's a 4x4 nearest-neighbor densification of the raster, with then 2:2 and 2:1:1 diagonal touchpoints identified (marked with outline) and smoothed out by changing the cells in bold. Note the categories need to be prioritized, since in the example above at the centre-right, A "beats out" C in terms of building a bridge. This densified raster can then be polygonized with enough breadcrumbs provided for vector smoothing algorithms (if desired) to further adjust the curves while keeping desired connectedness.
Before I muck around in python or build some fine-tuned combo of QGIS/Grass processing algorithms to implement this, am I reinventing the wheel? Or are there equivalent simpler solutions?
I'd be OK doing the diagonal smoothing and bridge-building after polygonization rather than in raster form, but solutions with e.g. + and - buffering the staircase-shaped polygons seem unnecessarily complicated, especially in then filling gaps and resolving overlaps.