Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from PIL import Image
  3. from math import *
  4. from random import random
  5.  
  6. weights = []
  7. weights.append([1, 0.7, 0.1])
  8. weights.append([0.5, 0.7, 0.9])
  9. neurons_2 = [0, 0, 0, 0]
  10. weights_2 = [
  11. [0,0.4],
  12. [1,0.4],
  13. [0.2,0.6],
  14. [0.4,0.7]]
  15. img_height = 150
  16. img_width = 150
  17. r, b, g = (0, 0, 0)
  18.  
  19. def network(x, y, weights):
  20. for i in range(len(neurons_2)):
  21. neurons_2[i] = x * weights_2[0][i] + y * weights_2[1][i]
  22. r = int(x * weights[0][0] + y * weights[1][0]) #R
  23. g = int(x * weights[0][1] + y * weights[1][1])#G
  24. b = int(x * weights[0][2] + y * weights[1][2]) #B
  25.  
  26. return r, g, b
  27.  
  28. network(10,25, weights)
  29.  
  30.  
  31.  
  32. img = Image.new("RGB", (img_height,img_width))
  33. img_pixels = img.load()
  34.  
  35. for x in range(img_height):
  36. for y in range(img_width):
  37. img_pixels[x, y] = network(x,y, weights)
  38. print(img_pixels[x, y])
  39.  
  40.  
  41. img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement