Advertisement
Guest User

Untitled

a guest
May 9th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def contrast_pixels(pixels_list):
  2.     rows_number = len(pixels_list)
  3.     columns_number = len(pixels_list[0])
  4.     counts = 0
  5.  
  6.     for i in range(rows_number):
  7.         for j in range(columns_number):
  8.             if j != columns_number - 1:
  9.                 if abs(pixels_list[i][j] - pixels_list[i][j+1]) > 128:
  10.                     counts += 1
  11.                     continue
  12.             if i != rows_number - 1:
  13.                 if abs(pixels_list[i][j] - pixels_list[i+1][j]) > 128:
  14.                     counts += 1
  15.     return counts
  16.  
  17. pixels = [[1, 130, 1], [130, 200, 210], [1, 250, 10]]
  18.  
  19. print(contrast_pixels(pixels))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement