#!/usr/bin/env python import sys from the_semantic_db_code import * from the_semantic_db_functions import * from the_semantic_db_processor import * C = context_list("image pixels") # start here: # google: "python extract pixel values from image" # http://stackoverflow.com/questions/138250/read-the-rgb-value-of-a-given-pixel-in-python-programatically # http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow # # good stuff here: # http://www.processing.org/tutorials/pixels/ # http://en.wikipedia.org/wiki/Standard_test_image # FERET database (DARPA/NIST face recognition database) # http://en.wikipedia.org/wiki/FERET_database from PIL import Image im = Image.open("image-play/Lenna.png") im = Image.open("image-play/220px-Lenna.png") pix = im.load() print(im.size) print(pix[30,30]) print(pix[100,100]) r,g,b,a = pix[200,200] print("r:",r) print("g:",g) print("b:",b) print("a:",a) w = im.size[0] h = im.size[1] print("w:",w) print("h:",h) #sys.exit(0) print() filename = "sw-examples/200-lenna.sw" with open(filename,'w') as f: for i in range(w): for j in range(h): # print(pix[i,j]) r,g,b,a = pix[i,j] f.write("value |pixel: " + str(i) + ": " + str(j) + "> => " + str(ket("r",r) + ket("g",g) + ket("b",b) + ket("a",a)) + "\n")