Advertisement
Guest User

im fkn retarded

a guest
Dec 6th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. class Solution:
  2. def imageSmoother(self, M: List[List[int]]) -> List[List[int]]:
  3. w=len(M[0])
  4. h=len(M)
  5. c=[]
  6. for y in range(0,h):
  7. l=[]
  8. m=[]
  9. r=[]
  10. for i in range(y-1,y+2):
  11. if i>=0 and i<h:
  12. m.append(M[i][0])
  13. if w>1:
  14. r.append(M[i][1])
  15. R=[]
  16. for x in range(1,w+1):
  17. R.append((int)(sum(l+m+r)/(len(l+m+r))))
  18. l=m
  19. m=r
  20. r=[]
  21. for i in range(y-1,y+2):
  22. if i>=0 and i<h and x+1<w:
  23. r.append(M[i][x+1])
  24. c.append(R)
  25. return c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement