Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def imageSmoother(self, M: List[List[int]]) -> List[List[int]]:
- w=len(M[0])
- h=len(M)
- c=[]
- for y in range(0,h):
- l=[]
- m=[]
- r=[]
- for i in range(y-1,y+2):
- if i>=0 and i<h:
- m.append(M[i][0])
- if w>1:
- r.append(M[i][1])
- R=[]
- for x in range(1,w+1):
- R.append((int)(sum(l+m+r)/(len(l+m+r))))
- l=m
- m=r
- r=[]
- for i in range(y-1,y+2):
- if i>=0 and i<h and x+1<w:
- r.append(M[i][x+1])
- c.append(R)
- return c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement