Do as asked Simple Approach
\n# Code\n\nclass Solution:\n    def resultGrid(self, image: List[List[int]], threshold: int) -> List[List[int]]:\n        a=[[[] for i in range(len(image[0]))]
\n# Code\n```\nclass Solution:\n    def resultGrid(self, image: List[List[int]], threshold: int) -> List[List[int]]:\n        a=[[[] for i in range(len(image[0]))] for j in range(len(image))]\n        def do(i,j):\n            su=0\n            tt=0\n            for p in range(i,i+3):\n                for q in range(j,j+3):\n                    su+=image[p][q]\n                    tt+=1\n                    if(p!=i):\n                        if(abs(image[p][q]-image[p-1][q])>threshold):\n                            return \n                    if(q!=j):\n                        if(abs(image[p][q]-image[p][q-1])>threshold):\n                            return\n            av=su//tt\n            for p in range(i,i+3):\n                for q in range(j,j+3):\n                    a[p][q].append(av)\n        for i in range(len(image)-2):\n            for j in range(len(image[0])-2):\n                do(i,j)\n        ans=[]\n        for i in range(len(image)):\n            ans.append([])\n            for j in range(len(image[0])):\n                if(a[i][j]==[]):\n                    ans[-1].append(image[i][j])\n                else:\n                    ans[-1].append(sum(a[i][j])//len(a[i][j]))\n        return ans\n        \n```
['Matrix', 'Simulation', 'Python3']