I'm a beginner to Python and Image Processing and have been trying to change the pixel values of an image using the following function. However I get an error saying- TypeError: 'instancemethod' object does not support item assignment on the 12th (last but one) line of the code Is there anyway to sort this out? This is my code:
from PIL import Image
import math
size=width,height=32,32
img=Image.new("L", size, "white")
pix=img.load
for i in range (0,31):
for j in range (0,31):
sqsum=i*i+j*j
sqrt=math.sqrt(sqsum)
sine=math.sin(sqrt)
absval=abs(sine)
pix[i,j]=absval
img.show()
img.loadbefore the loop. Should bepix = img.load(). - Daniel Roseman