Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from PIL import Image
- from math import *
- from random import random
- weights = []
- weights.append([1, 0.7, 0.1])
- weights.append([0.5, 0.7, 0.9])
- neurons_2 = [0, 0, 0, 0]
- weights_2 = [
- [0,0.4],
- [1,0.4],
- [0.2,0.6],
- [0.4,0.7]]
- img_height = 150
- img_width = 150
- r, b, g = (0, 0, 0)
- def network(x, y, weights):
- for i in range(len(neurons_2)):
- neurons_2[i] = x * weights_2[0][i] + y * weights_2[1][i]
- r = int(x * weights[0][0] + y * weights[1][0]) #R
- g = int(x * weights[0][1] + y * weights[1][1])#G
- b = int(x * weights[0][2] + y * weights[1][2]) #B
- return r, g, b
- network(10,25, weights)
- img = Image.new("RGB", (img_height,img_width))
- img_pixels = img.load()
- for x in range(img_height):
- for y in range(img_width):
- img_pixels[x, y] = network(x,y, weights)
- print(img_pixels[x, y])
- img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement