Concise & Readable Python Solution
\ndef resultGrid(self, image: List[List[int]], threshold: int) -> List[List[int]]:\n    m = len(image); n = len(image[0])\n    \n    isValid = lambda a,b,c,d: a
```\ndef resultGrid(self, image: List[List[int]], threshold: int) -> List[List[int]]:\n    m = len(image); n = len(image[0])\n    \n    isValid = lambda a,b,c,d: abs(image[a][b] - image[c][d]) <= threshold\n    def check_adjacent(i, j, bounds):\n        tl_i, tl_j, br_i, br_j = bounds\n        isRegion = 1\n        for n_i,n_j in [(i,j+1), (i+1,j), (i,j-1), (i-1,j)]:\n            if tl_i <= n_i <= br_i and tl_j <= n_j <= br_j:\n                isRegion &= isValid(i,j, n_i, n_j)\n        return isRegion\n    \n    def iterate_region(r, c, avg=-1):\n        isRegion = 1; SUM = 0\n        bounds = [r, c, r+2, c+2]\n        for i in range(r, r+3):\n            for j in range(c, c+3):\n                if avg != -1:\n                    res[i][j] += avg\n                    region_count[i][j] += 1\n                else:\n                    SUM += image[i][j]\n                    isRegion &= check_adjacent(i, j, bounds)\n        return SUM if isRegion else -1\n    \n    res = [[0]*n for _ in range(m)]\n    region_count = [[0]*n for _ in range(m)]\n    for r in range(m-2):\n        for c in range(n-2):\n            SUM = iterate_region(r, c)\n            if SUM != -1:\n                iterate_region(r, c, SUM//9)\n    \n    for i in range(m):\n        for j in range(n):\n            if region_count[i][j] == 0:\n                res[i][j] = image[i][j]\n            else:\n                res[i][j] //= region_count[i][j]\n    \n    return res\n```
['Matrix', 'Python']