Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from PIL import Image
- img = Image.open("56.jpg")
- pixels = img.load()
- #factor = int(input('factor:'))
- maxLoad = img.width * img.height
- onePer = maxLoad / 100
- k = 0
- factor = random.randint(0,100)
- for i in range(img.width):
- for j in range(img.height):
- if(i*j>k*10*onePer):
- print("Обработано", k*10, "%" )
- k+=1
- rand = random.randint(-factor, factor)
- a = pixels[i, j][0] + rand
- b = pixels[i, j][1] + rand
- c = pixels[i, j][2] + rand
- if (a < 0):
- a = 0
- if (b < 0):
- b = 0
- if (c < 0):
- c = 0
- if (a > 255):
- a = 255
- if (b > 255):
- b = 255
- if (c > 255):
- c = 255
- pixels[i, j] = (a, b, c)
- img.show()
- img.save("13.jpg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement