Guest User

Untitled

a guest
Jul 30th, 2023
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. width_x= 4947 ; height_x = 3092
  2. smearlock = False
  3.  
  4. def setup():
  5.  
  6. global img, smearlock
  7.  
  8. img = loadImage("marek-piwnicki-D5T8zRDUun0-unsplash.jpg")
  9. size(width_x, height_x)
  10.  
  11. def draw():
  12.  
  13. global img, smearlock
  14. background(0)
  15.  
  16. if not smearlock:
  17. sorter(img, 'br', 'lt', 200)
  18. image(img, 0, 0, width, height)
  19.  
  20.  
  21. def sorter(im, col, sign, thresh):
  22.  
  23. global smearlock
  24.  
  25. for x in range(im.width):
  26. for y in range(im.height):
  27.  
  28. loc = x + y * im.width
  29. smear = (x -1) + y * im.width
  30.  
  31. if col == 'r':
  32. val = red(im.pixels[loc])
  33. if col == 'g':
  34. val = green(im.pixels[loc])
  35. if col == 'b':
  36. val = blue(im.pixels[loc])
  37. if col == 'br':
  38. val = brightness(im.pixels[loc])
  39. if col == 'h':
  40. val = hue(im.pixels[loc])
  41. if col == 's':
  42. val = saturation(im.pixels[loc])
  43.  
  44. if thresh > 255:
  45. thresh = 255
  46. if thresh < 0:
  47. thresh = 0
  48.  
  49. if sign == 'gt':
  50. if val > thresh:
  51. im.pixels[loc] = im.pixels[smear]
  52.  
  53. if sign == 'lt':
  54. if val < thresh:
  55. im.pixels[loc] = im.pixels[smear]
  56.  
  57.  
  58. smearlock = True
  59.  
  60. def keyPressed():
  61.  
  62. if key == 's':
  63. saveFrame("####.jpg")
Advertisement
Add Comment
Please, Sign In to add comment